Skip to content

Commit

Permalink
Add impls for Scan and GcSafe for std::collections::{BTreeMap, BTreeSet}
Browse files Browse the repository at this point in the history
  • Loading branch information
alekratz authored and Others committed Jul 30, 2020
1 parent 0b9fbcd commit 1e415f2
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/scan/std_impls.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::cell::{Cell, RefCell};
use std::collections::{HashMap, HashSet};
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
use std::hash::BuildHasher;
use std::ops::Deref;
use std::sync::{Arc, Mutex, RwLock, TryLockError};
Expand Down Expand Up @@ -42,6 +42,29 @@ unsafe impl<K: Scan, V: Scan, S: BuildHasher> Scan for HashMap<K, V, S> {
// FIXME: Would a bad build hasher cause problems?
unsafe impl<K: GcSafe, V: GcSafe, S: BuildHasher> GcSafe for HashMap<K, V, S> {}

unsafe impl<T: Scan> Scan for BTreeSet<T> {
#[inline]
fn scan(&self, scanner: &mut Scanner<'_>) {
for e in self {
scanner.scan(e)
}
}
}

unsafe impl<T: GcSafe> GcSafe for BTreeSet<T> {}

unsafe impl<K: Scan, V: Scan> Scan for BTreeMap<K, V> {
#[inline]
fn scan(&self, scanner: &mut Scanner<'_>) {
for (k, v) in self {
scanner.scan(k);
scanner.scan(v);
}
}
}

unsafe impl<K: GcSafe, V: GcSafe> GcSafe for BTreeMap<K, V> {}

unsafe impl<T: Copy> Scan for Cell<T>
where
T: GcSafe,
Expand Down

0 comments on commit 1e415f2

Please sign in to comment.