Created
February 8, 2022 18:58
-
-
Save technorav3nn/c8a3928af65457233dc5bfade994c051 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| trait TPerson { | |
| fn get_name(&self) -> String; | |
| } | |
| struct Person<'a> { | |
| name: &'a str | |
| } | |
| impl TPerson for Person<'_> { | |
| fn get_name(&self) -> String { | |
| return String::from(self.name) | |
| } | |
| } | |
| fn main() { | |
| let me = Person { | |
| name: "Colin" | |
| }; | |
| let my_name = me.get_name(); | |
| println!("{}", &my_name) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment