Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. #[derive(Clone)]
  2. pub struct Face {
  3. has_eyes: bool,
  4. }
  5.  
  6. pub struct Cat {
  7. face: Face,
  8. }
  9.  
  10. fn from_face(face: &Face) -> Cat {
  11. Cat {
  12. face: *face,
  13. }
  14. }
  15.  
  16.  
  17. fn main() {
  18. let face = Face{ has_eyes: true };
  19. let _cloned_face = face.clone();
  20. let _cat = from_face(&face);
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement