mirror of
https://github.com/rust-lang/rustlings.git
synced 2025-12-01 22:51:45 +02:00
move_semantics2 solution
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
// Make the test pass by finding a way to keep both Vecs separate!
|
||||
|
||||
fn fill_vec(vec: Vec<i32>) -> Vec<i32> {
|
||||
let mut vec = vec;
|
||||
|
||||
@@ -16,13 +14,15 @@ fn main() {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
// TODO: Make both vectors `vec0` and `vec1` accessible at the same time to
|
||||
// fix the compiler error in the test.
|
||||
#[test]
|
||||
fn move_semantics2() {
|
||||
let vec0 = vec![22, 44, 66];
|
||||
|
||||
let vec1 = fill_vec(vec0);
|
||||
|
||||
assert_eq!(vec0, vec![22, 44, 66]);
|
||||
assert_eq!(vec1, vec![22, 44, 66, 88]);
|
||||
assert_eq!(vec0, [22, 44, 66]);
|
||||
assert_eq!(vec1, [22, 44, 66, 88]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user