Skip to content

Commit

Permalink
Rc to Arc
Browse files Browse the repository at this point in the history
  • Loading branch information
Eh2406 committed Feb 2, 2024
1 parent 9b4afc4 commit 53a3cd8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
6 changes: 3 additions & 3 deletions src/internal/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//! to write a functional PubGrub algorithm.
use std::error::Error;
use std::rc::Rc;
use std::sync::Arc;

use crate::error::PubGrubError;
use crate::internal::arena::Arena;
Expand Down Expand Up @@ -316,9 +316,9 @@ impl<P: Package, VS: VersionSet, Priority: Ord + Clone> State<P, VS, Priority> {
&self.incompatibility_store,
&precomputed,
);
precomputed.insert(id, Rc::new(tree));
precomputed.insert(id, Arc::new(tree));
}
// Now the user can refer to the entire tree from its root.
Rc::into_inner(precomputed.remove(&incompat).unwrap()).unwrap()
Arc::into_inner(precomputed.remove(&incompat).unwrap()).unwrap()
}
}
4 changes: 2 additions & 2 deletions src/internal/incompatibility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//! that should never be satisfied all together.
use std::fmt;
use std::rc::Rc;
use std::sync::Arc;

use crate::internal::arena::{Arena, Id};
use crate::internal::small_map::SmallMap;
Expand Down Expand Up @@ -228,7 +228,7 @@ impl<P: Package, VS: VersionSet> Incompatibility<P, VS> {
self_id: Id<Self>,
shared_ids: &Set<Id<Self>>,
store: &Arena<Self>,
precomputed: &Map<Id<Self>, Rc<DerivationTree<P, VS>>>,
precomputed: &Map<Id<Self>, Arc<DerivationTree<P, VS>>>,
) -> DerivationTree<P, VS> {
match store[self_id].kind.clone() {
Kind::DerivedFrom(id1, id2) => {
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@
//! with a cache, you may want to know that some versions
//! do not exist in your cache.
#![allow(clippy::rc_buffer)]
#![warn(missing_docs)]

pub mod error;
Expand Down
14 changes: 7 additions & 7 deletions src/report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use std::fmt;
use std::ops::Deref;
use std::rc::Rc;
use std::sync::Arc;

use crate::package::Package;
use crate::term::Term;
Expand Down Expand Up @@ -65,9 +65,9 @@ pub struct Derived<P: Package, VS: VersionSet> {
/// and refer to the explanation for the other times.
pub shared_id: Option<usize>,
/// First cause.
pub cause1: Rc<DerivationTree<P, VS>>,
pub cause1: Arc<DerivationTree<P, VS>>,
/// Second cause.
pub cause2: Rc<DerivationTree<P, VS>>,
pub cause2: Arc<DerivationTree<P, VS>>,
}

impl<P: Package, VS: VersionSet> DerivationTree<P, VS> {
Expand All @@ -84,8 +84,8 @@ impl<P: Package, VS: VersionSet> DerivationTree<P, VS> {
DerivationTree::External(_) => {}
DerivationTree::Derived(derived) => {
match (
Rc::make_mut(&mut derived.cause1),
Rc::make_mut(&mut derived.cause2),
Arc::make_mut(&mut derived.cause1),
Arc::make_mut(&mut derived.cause2),
) {
(DerivationTree::External(External::NoVersions(p, r)), ref mut cause2) => {
cause2.collapse_no_versions();
Expand All @@ -102,8 +102,8 @@ impl<P: Package, VS: VersionSet> DerivationTree<P, VS> {
.unwrap_or_else(|| self.to_owned());
}
_ => {
Rc::make_mut(&mut derived.cause1).collapse_no_versions();
Rc::make_mut(&mut derived.cause2).collapse_no_versions();
Arc::make_mut(&mut derived.cause1).collapse_no_versions();
Arc::make_mut(&mut derived.cause2).collapse_no_versions();
}
}
}
Expand Down

0 comments on commit 53a3cd8

Please sign in to comment.