Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created July 19, 2019 10:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rust-play/4b6fd10d5a9335c50208ef2c60e4c718 to your computer and use it in GitHub Desktop.
Save rust-play/4b6fd10d5a9335c50208ef2c60e4c718 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
struct Cat {
weight: i32,
}
trait Animal {
type Weight;
fn get_weight(&self) -> &Self::Weight;
}
impl Animal for Cat {
type Weight = i32;
fn get_weight(&self) -> &i32 {
&self.weight
}
}
fn main() {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment