I'm writing a simple builder. I'd like to have a builder method consume self, and also consume a Vec<Node> and append it to a Vec<Node> that self already owns.
I have this method:
pub fn with_nodes(mut self, mut nodes: Vec<Node>) -> Graph {
self.nodes.append(&nodes);
self
}
nodes is a non-reference because I want to consume it, and it's mut because Vec<>::append() mutates its argument.
Problem is, I get:
46 | self.nodes.append(&nodes);
| ^^^^^^ types differ in mutability
|
= note: expected mutable reference `&mut Vec<Node>`
found reference `&Vec<Node>`
How come that nodes is immutable, as it's explicitly marked mut? How else can I make the argument a locally mutable Vec?