Request Guidance Inferring Rust DOT DSL Requirents

I’m completely baffled trying to figure out the DOT DSL exercise’s requirements from its tests. I hope someone can help.

For instance, given the “builder pattern” requirement illustrated by this passage in the graph_with_attributes test, "Graph"s with_nodes() function needs to return a &mut Graph.

let graph = Graph::new()
    .with_nodes(&nodes)
    .with_edges(&edges)
    .with_attrs(&attrs);

If it is implemented in that way, though, the tests won’t compile, because this line

let graph = Graph::new().with_nodes(&nodes);

is an error: “Temporary value dropped while borrowed”. (That line appears in the tests a lot.)

Another example is the graph_with_one_node test, which starts with

let nodes = vec![Node::new("a")];
let graph = Graph::new().with_nodes(&nodes);

which implies that the “Graph” struct’s with_nodes function should be passed a &Vec<Node>, but then the graph_with_one_node_with_keywords test starts with

let nodes = vec![Node::new("a").with_attrs(&[("color", "green")])];
let graph = Graph::new().with_nodes(&nodes);

which would mean that it takes a &Vec<&mut Node>. I guess there’s some way to accomplish this that I just don’t know about?

The builder methods should return an owned Self, not &mut Self.

D’oh! I was led astray by the Builder Pattern page linked to the exercise, whose examples return mutable vectors. Given my faulty understanding of Rust’s memory system, that seemed like a requirement.

Thank you for the assist.