Category "borrow-checker"

Rust: Move issue in while loop

I have the following rust code and for the life of me I cant workout why I am getting a borrow-checker issue with this value and why does it get moved as part o

Mutable borrow inside loop

I have a vector of tuples, each containing two strings. I want to transfer (one of) the two strings as a mutable reference into a hashmap. The other string is a

Avoid using partially moved value in match statement

The solution provided in question 38553513 does not work for me. Consider these types and functions: pub enum Parameter { ParameterTypeA { n: i32 }, Par

Decoupling ownership from vector

I'm creating factory methods for objects with shared references. The compiler cannot see that the objects from a Vec are not referenced outside the local scope,

Implementing Borrow trait for a type with a lifetime

I'm trying to use. strongly typed wrapper for a "keys" in my program, so that I don't mistake arbitrary strings for a Key. I have: #[derive(Debug, Clone, Partia

Why Rust prevents from multiple mutable references?

Like in the topic, why Rust prevents from multiple mutable references? I have read chapter in rust-book, and I understand that when we have multi-threaded code