Guest User

Untitled

a guest
Jul 19th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. use std::rc::Rc;
  2.  
  3. #[derive(Debug)]
  4. struct Thing {
  5. nums: Vec<f64>
  6. }
  7.  
  8. fn build_things() -> Vec<Thing> {
  9. (0..10).map(|_| Thing {nums: vec![1.0, 2.0, 3.0]}).collect()
  10. }
  11.  
  12.  
  13. fn build_new_things<'a>(things: Vec<&'a Thing>) -> Vec<&'a Thing> {
  14. let sliced_things = &things[..];
  15.  
  16. let mut new_things: Vec<&Thing> = Vec::new();
  17. for thing in sliced_things {
  18. new_things.push(thing);
  19. }
  20. new_things
  21. }
  22.  
  23. fn main() {
  24. let things = build_things();
  25. let new_things = build_new_things(things.iter().collect());
  26. let newer_things = build_new_things(new_things);
  27. println!("{:?}", newer_things);
  28. }
Add Comment
Please, Sign In to add comment