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 Repository { | |
| fn save(&self); | |
| } | |
| struct ARepository {} | |
| impl Repository for ARepository { | |
| fn save(&self) { | |
| println!("has been save !!!"); | |
| } | |
| } |
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
| use std::rc::Rc; | |
| /* | |
| Box -> Référencer une valeur sans connaitre à la compilation sa taille en mémoire | |
| Rc -> reference count | |
| Arc -> atomic reference count | |
| */ | |
| struct Car { | |
| engine: Engine, |
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
| use std::any::Any; | |
| trait Animal { | |
| fn give_my_name(&self) -> String; | |
| fn eat(&self) { | |
| println!("miam !!!!"); | |
| } | |
| fn as_any(&self) -> &dyn Any; |