Destructure a vector into variables and give away ownership?
问题 I have a struct struct Foo { foo1: String, foo2: String, foo3: String, foo4: String, // ... } I would like to create an instance of Foo from a vector. let x = vec!["a".to_string(), "b".to_string(), "c".to_string(), "d".to_string()]; match x.as_slice() { &[ref a, ref b, ref c, ref d] => { let foo = Foo { foo1: a.to_string(), foo2: b.to_string(), foo3: c.to_string(), foo4: d.to_string(), }; }, _ => unreachable!(), } Do I have to copy the strings? Is there any better way to destructure the