pub struct ArcIntern<T: Eq + Hash + Send + Sync + 'static + ?Sized> { /* private fields */ }
Expand description
A pointer to a reference-counted interned object.
The interned object will be held in memory only until its reference count reaches zero.
§Example
use arc_interner::ArcIntern;
let x = ArcIntern::new("hello");
let y = ArcIntern::new("world");
assert_ne!(x, y);
assert_eq!(x, ArcIntern::new("hello"));
assert_eq!(*x, "hello"); // dereference an ArcIntern like a pointer
Implementations§
Source§impl<T: Eq + Hash + Send + Sync + 'static> ArcIntern<T>
impl<T: Eq + Hash + Send + Sync + 'static> ArcIntern<T>
Sourcepub fn new(val: T) -> ArcIntern<T>
pub fn new(val: T) -> ArcIntern<T>
Intern a value. If this value has not previously been
interned, then new
will allocate a spot for the value on the
heap. Otherwise, it will return a pointer to the object
previously allocated.
Note that ArcIntern::new
is a bit slow, since it needs to check
a DashMap
which contains its own mutexes.
Trait Implementations§
Source§impl<'de, T: Eq + Hash + Send + Sync + 'static + ?Sized + Deserialize<'de>> Deserialize<'de> for ArcIntern<T>
impl<'de, T: Eq + Hash + Send + Sync + 'static + ?Sized + Deserialize<'de>> Deserialize<'de> for ArcIntern<T>
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
Source§impl<T: Eq + Hash + Send + Sync + Ord + ?Sized> Ord for ArcIntern<T>
impl<T: Eq + Hash + Send + Sync + Ord + ?Sized> Ord for ArcIntern<T>
Source§impl<T: Eq + Hash + Send + Sync + ?Sized> PartialEq for ArcIntern<T>
Efficiently compares two interned values by comparing their pointers.
impl<T: Eq + Hash + Send + Sync + ?Sized> PartialEq for ArcIntern<T>
Efficiently compares two interned values by comparing their pointers.
Source§impl<T: Eq + Hash + Send + Sync + PartialOrd + ?Sized> PartialOrd for ArcIntern<T>
impl<T: Eq + Hash + Send + Sync + PartialOrd + ?Sized> PartialOrd for ArcIntern<T>
impl<T: Eq + Hash + Send + Sync + ?Sized> Eq for ArcIntern<T>
Auto Trait Implementations§
impl<T> Freeze for ArcIntern<T>where
T: ?Sized,
impl<T> RefUnwindSafe for ArcIntern<T>where
T: RefUnwindSafe + ?Sized,
impl<T> Send for ArcIntern<T>where
T: ?Sized,
impl<T> Sync for ArcIntern<T>where
T: ?Sized,
impl<T> Unpin for ArcIntern<T>where
T: ?Sized,
impl<T> UnwindSafe for ArcIntern<T>where
T: RefUnwindSafe + ?Sized,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more