clone.rs 251 字节
Newer Older
1 2
#[test]
fn test_borrowed_clone() {
T
Tobias Bucher 已提交
3
    let x = 5;
F
Florian Hahn 已提交
4 5
    let y: &i32 = &x;
    let z: &i32 = (&y).clone();
6 7 8 9 10
    assert_eq!(*z, 5);
}

#[test]
fn test_clone_from() {
T
Tobias Bucher 已提交
11 12
    let a = box 5;
    let mut b = box 10;
13 14 15
    b.clone_from(&a);
    assert_eq!(*b, 5);
}