Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. struct WideList<T> {
  2. hd: T,
  3. tl: Option<Box<WideList<(T, T)>>>
  4. }
  5.  
  6. impl<T> Clone for WideList<T>
  7. where
  8. T: Clone,
  9. Option<Box<WideList<(T, T)>>>: Clone
  10. {
  11. fn clone(&self) -> WideList<T> {
  12. WideList {
  13. hd: self.hd.clone(),
  14. tl: self.tl.clone()
  15. }
  16. }
  17. }
  18.  
  19. fn main() {
  20. let x = WideList { hd: 1i32, tl: Some(Box::new(WideList { hd: (2i32, 3i32), tl: None })) };
  21. x.clone()
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement