Skip to content

Commit

Permalink
use make_mut for cleaner code
Browse files Browse the repository at this point in the history
  • Loading branch information
Eh2406 committed Apr 6, 2018
1 parent 736c3d7 commit 04fbc5f
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/cargo/core/resolver/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ impl Context {
&*link
);
}
let mut inner: Vec<_> = (**prev).clone();
inner.push(summary.clone());
*prev = Rc::new(inner);
Rc::make_mut(prev).push(summary.clone());
return Ok(false);
}
debug!("checking if {} is already activated", summary.package_id());
Expand Down Expand Up @@ -246,15 +244,13 @@ impl Context {
if !reqs.used.is_empty() {
let pkgid = s.package_id();

let set = self.resolve_features
let set = Rc::make_mut(self.resolve_features
.entry(pkgid.clone())
.or_insert_with(|| Rc::new(HashSet::new()));
.or_insert_with(|| Rc::new(HashSet::new())));

let mut inner: HashSet<_> = (**set).clone();
for feature in reqs.used {
inner.insert(InternedString::new(feature));
set.insert(InternedString::new(feature));
}
*set = Rc::new(inner);
}

Ok(ret)
Expand Down

0 comments on commit 04fbc5f

Please sign in to comment.