stateright / stateright

A model checker for implementing distributed systems.

Home Page:https://docs.rs/stateright

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`DGraph::with_path` should take the ownership of `self` to avoid cloning.

HaoYang670 opened this issue · comments

pub fn with_path(&self, path: Vec<u8>) -> Self {
let mut src = *path.first().unwrap();
DGraph {
inits: {
let mut inits = self.inits.clone();
inits.insert(src);
inits
},
edges: {
let mut edges = self.edges.clone();
for &dst in path.iter().skip(1) {
edges.entry(src).or_default().insert(dst);
src = dst;
}
edges
},
property: self.property.clone(),
}
}

It is better to let with_path consume self to avoid coping.

pub fn with_path(mut self, path: Vec<u8>) -> Self {
    ...
}