-
-
Save rust-play/2c4f7a18f3896089c2bf4e53834dd5e1 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Abc<T> { | |
name: String, | |
value: T, | |
} | |
impl<T> std::fmt::Debug for Abc<T> { | |
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | |
write!(f, "Abc({})", self.name) | |
} | |
} | |
#[derive(Debug)] | |
enum Item<T> { | |
Alpha, | |
Beta(Abc<T>) | |
} | |
struct Xyz { | |
value: i32, | |
} | |
fn main() { | |
let abc = Abc { | |
name: "abc".to_string(), | |
value: Xyz { value: 1 }, | |
}; | |
println!("{:?}", abc); | |
let item = Item::Beta(abc); | |
println!("{:?}", item); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment