aboutsummaryrefslogtreecommitdiff
path: root/examples/generics/printer.rs
diff options
context:
space:
mode:
authorHampusM <hampus@hampusmat.com>2022-07-24 15:58:30 +0200
committerHampusM <hampus@hampusmat.com>2022-07-24 15:58:30 +0200
commit5335cdad99a6d566ea6e83f97012c7954ba93c45 (patch)
treeb4c91634b34f6d3858d6dd210afb609d9a1f76d7 /examples/generics/printer.rs
parent5ea16d1e5bf716831bc8c54c5c4c86229d7e0463 (diff)
feat: add support for generics
Diffstat (limited to 'examples/generics/printer.rs')
-rw-r--r--examples/generics/printer.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/examples/generics/printer.rs b/examples/generics/printer.rs
new file mode 100644
index 0000000..4307c4f
--- /dev/null
+++ b/examples/generics/printer.rs
@@ -0,0 +1,24 @@
+use std::fmt::Display;
+
+use syrette::injectable;
+
+use crate::interfaces::printer::IPrinter;
+
+pub struct Printer {}
+
+#[injectable]
+impl Printer
+{
+ pub fn new() -> Self
+ {
+ Self {}
+ }
+}
+
+impl<Printable: Display> IPrinter<Printable> for Printer
+{
+ fn print(&self, out: Printable)
+ {
+ println!("{}", out);
+ }
+}