Convert vector of structs to vector of references



examples/vectors/convert-vector-of-structs-to-vector-of-references/src/main.rs
#[derive(Debug)]
#[allow(dead_code)]
struct Something {
    number: i32,
    text: String,
    numbers: Vec<i32>,
}

fn main() {
    let va: Vec<Something> = vec![
        Something {
            number: 1,
            text: String::from("small"),
            numbers: vec![1, 2, 3],
        },
        Something {
            number: 11,
            text: String::from("medium"),
            numbers: vec![11, 12],
        },
        Something {
            number: 101,
            text: String::from("large"),
            numbers: vec![101],
        },
    ];
    println!("{:#?}", va);

    //let vb = &va.iter().collect::<Vec<&Something>>();
    let vb = &va.iter().collect::<Vec<_>>();
    println!("{:#?}", vb);
    println!("{:#?}", va);
}

[
    Something {
        number: 1,
        text: "small",
        numbers: [
            1,
            2,
            3,
        ],
    },
    Something {
        number: 11,
        text: "medium",
        numbers: [
            11,
            12,
        ],
    },
    Something {
        number: 101,
        text: "large",
        numbers: [
            101,
        ],
    },
]
[
    Something {
        number: 1,
        text: "small",
        numbers: [
            1,
            2,
            3,
        ],
    },
    Something {
        number: 11,
        text: "medium",
        numbers: [
            11,
            12,
        ],
    },
    Something {
        number: 101,
        text: "large",
        numbers: [
            101,
        ],
    },
]
[
    Something {
        number: 1,
        text: "small",
        numbers: [
            1,
            2,
            3,
        ],
    },
    Something {
        number: 11,
        text: "medium",
        numbers: [
            11,
            12,
        ],
    },
    Something {
        number: 101,
        text: "large",
        numbers: [
            101,
        ],
    },
]