diff options
Diffstat (limited to 'src/ext_traits')
| -rw-r--r-- | src/ext_traits/Cargo.toml | 6 | ||||
| -rw-r--r-- | src/ext_traits/src/main.rs | 14 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/ext_traits/Cargo.toml b/src/ext_traits/Cargo.toml new file mode 100644 index 0000000..49354b6 --- /dev/null +++ b/src/ext_traits/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "ext_traits" +version = "0.1.0" +edition = "2024" + +[dependencies] diff --git a/src/ext_traits/src/main.rs b/src/ext_traits/src/main.rs new file mode 100644 index 0000000..f5d8886 --- /dev/null +++ b/src/ext_traits/src/main.rs @@ -0,0 +1,14 @@ +use std::fmt; + +struct Wrapper(Vec<String>); + +impl fmt::Display for Wrapper { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "[{}]", self.0.join(", ")) + } +} + +fn main() { + let w = Wrapper(vec![String::from("hello"), String::from("world")]); + println!("w = {w}"); +} |
