pub struct OccupiedEntry<'a, P, T> { /* private fields */ }Expand description
A mutable view into an occupied entry. An occupied entry represents a node that is already present on the tree.
Implementations§
Source§impl<P: Prefix, T> OccupiedEntry<'_, P, T>
impl<P: Prefix, T> OccupiedEntry<'_, P, T>
Sourcepub fn key(&self) -> &P
pub fn key(&self) -> &P
Gets a reference to the key in the entry. This is the key that is currently stored, and not the key that was used in the insert.
use prefix_trie::map::Entry;
let mut pm: PrefixMap<ipnet::Ipv4Net, _> = PrefixMap::new();
pm.insert("192.168.1.0/24".parse()?, 1);
match pm.entry("192.168.1.1/24".parse()?) {
Entry::Occupied(e) => assert_eq!(e.key(), &"192.168.1.0/24".parse()?),
Entry::Vacant(_) => unreachable!(),
}Sourcepub fn get(&self) -> &T
pub fn get(&self) -> &T
Gets a reference to the value in the entry.
use prefix_trie::map::Entry;
let mut pm: PrefixMap<ipnet::Ipv4Net, _> = PrefixMap::new();
pm.insert("192.168.1.0/24".parse()?, 1);
match pm.entry("192.168.1.0/24".parse()?) {
Entry::Occupied(e) => assert_eq!(e.get(), &1),
Entry::Vacant(_) => unreachable!(),
}Sourcepub fn get_mut(&mut self) -> &mut T
pub fn get_mut(&mut self) -> &mut T
Gets a mutable reference to the value in the entry.
Prefixes are not stored verbatim. They are reconstructed from the trie position, so host bits masked out by the prefix length are not preserved.
use prefix_trie::map::Entry;
let mut pm: PrefixMap<ipnet::Ipv4Net, _> = PrefixMap::new();
pm.insert("192.168.1.0/24".parse()?, 1);
match pm.entry("192.168.1.0/24".parse()?) {
Entry::Occupied(mut e) => *e.get_mut() += 1,
Entry::Vacant(_) => unreachable!(),
}
assert_eq!(pm.get(&"192.168.1.0/24".parse()?), Some(&2));Sourcepub fn insert(self, v: T) -> T
pub fn insert(self, v: T) -> T
Insert a new value into the entry, returning the old value.
use prefix_trie::map::Entry;
let mut pm: PrefixMap<ipnet::Ipv4Net, _> = PrefixMap::new();
pm.insert("192.168.1.0/24".parse()?, 1);
match pm.entry("192.168.1.0/24".parse()?) {
Entry::Occupied(mut e) => assert_eq!(e.insert(10), 1),
Entry::Vacant(_) => unreachable!(),
}
assert_eq!(pm.get(&"192.168.1.0/24".parse()?), Some(&10));Sourcepub fn remove(self) -> T
pub fn remove(self) -> T
Remove the current value and return it. Empty trie nodes may be left in place (the same
effect as PrefixMap::remove_keep_tree).
use prefix_trie::map::Entry;
let mut pm: PrefixMap<ipnet::Ipv4Net, i32> = PrefixMap::new();
pm.insert("192.168.1.0/24".parse()?, 1);
match pm.entry("192.168.1.0/24".parse()?) {
Entry::Occupied(mut e) => assert_eq!(e.remove(), 1),
Entry::Vacant(_) => unreachable!(),
}
assert_eq!(pm.get(&"192.168.1.0/24".parse()?), None);Auto Trait Implementations§
impl<'a, P, T> !RefUnwindSafe for OccupiedEntry<'a, P, T>
impl<'a, P, T> !UnwindSafe for OccupiedEntry<'a, P, T>
impl<'a, P, T> Freeze for OccupiedEntry<'a, P, T>where
P: Freeze,
impl<'a, P, T> Send for OccupiedEntry<'a, P, T>
impl<'a, P, T> Sync for OccupiedEntry<'a, P, T>
impl<'a, P, T> Unpin for OccupiedEntry<'a, P, T>where
P: Unpin,
impl<'a, P, T> UnsafeUnpin for OccupiedEntry<'a, P, T>where
P: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Returns the layout of the type.
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Returns whether the given value has been niched. Read more
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
Writes data to
out indicating that a T is niched.