Created
June 24, 2019 16:03
-
-
Save octave99/edc7e75e5568bccf1ee6de1ed2612c63 to your computer and use it in GitHub Desktop.
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
pub struct MyStruct<T> { | |
pub value: T, | |
} | |
impl MyStruct<u32> { | |
fn new(value: u32) -> Self { | |
MyStruct { value } | |
} | |
} | |
impl MyStruct<String> { | |
fn new(value: &str) -> Self { | |
MyStruct { | |
value: value.to_owned(), | |
} | |
} | |
} | |
fn main() { | |
let mut m = MyStruct::<u32>::new(1); | |
let n = MyStruct::<String>::new("etst"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment