Skip to content

Instantly share code, notes, and snippets.

@octave99
Created June 24, 2019 16:03
Show Gist options
  • Save octave99/edc7e75e5568bccf1ee6de1ed2612c63 to your computer and use it in GitHub Desktop.
Save octave99/edc7e75e5568bccf1ee6de1ed2612c63 to your computer and use it in GitHub Desktop.
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