Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::rc::Rc;
- #[derive(Debug)]
- struct Thing {
- nums: Vec<f64>
- }
- fn build_things() -> Vec<Thing> {
- (0..10).map(|_| Thing {nums: vec![1.0, 2.0, 3.0]}).collect()
- }
- fn build_new_things<'a>(things: Vec<&'a Thing>) -> Vec<&'a Thing> {
- let sliced_things = &things[..];
- let mut new_things: Vec<&Thing> = Vec::new();
- for thing in sliced_things {
- new_things.push(thing);
- }
- new_things
- }
- fn main() {
- let things = build_things();
- let new_things = build_new_things(things.iter().collect());
- let newer_things = build_new_things(new_things);
- println!("{:?}", newer_things);
- }
Add Comment
Please, Sign In to add comment