M
M
Mr4x2016-03-25 09:45:27
Programming
Mr4x, 2016-03-25 09:45:27

How to use the moved value?

I'm trying to do something like this:

let mut people = HashMap::new();

for a in 0..10 {
    for b in 0..10 {
        let id = format!("{}-{}", a, b);
        people.insert(id, Person::new(id));
    }
}

How to use `moved` id value?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Orlov, 2016-03-25
@Maxim_Samburskiy

Use a copy of a string?
people.insert(id.clone(), Person::new(id.clone()))
Perhaps one clone() is enough - I'm just learning rust myself.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question