Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trait HasS {
- fn get_s(&self) -> String;
- }
- struct Foo {}
- impl HasS for Foo {
- fn get_s(&self) -> String {
- String::from("Foo")
- }
- }
- impl HasS for &Foo {
- fn get_s(&self) -> String {
- String::from("*Foo")
- }
- }
- fn main() {
- let foo = Foo{};
- println!("{}", foo.get_s());
- println!("{}", (&&foo).get_s());
- }
Add Comment
Please, Sign In to add comment