[][src]Struct abi_stable::std_types::map::ROccupiedEntry

#[repr(C)]pub struct ROccupiedEntry<'a, K, V> { /* fields omitted */ }

A handle into an occupied entry in a map.

Implementations

impl<'a, K, V> ROccupiedEntry<'a, K, V>[src]

pub fn key(&self) -> &K[src]

Gets a reference to the key of the entry.

Example

use abi_stable::std_types::map::{REntry,RHashMap};

let mut map=RHashMap::<u32,u32>::new();

map.insert(0,100);

match map.entry(0) {
    REntry::Occupied(entry)=>{
        assert_eq!(entry.key(),&0);
    }
    REntry::Vacant(_)=>unreachable!(),
};

pub fn get(&self) -> &V[src]

Gets a reference to the value in the entry.

Example

use abi_stable::std_types::map::{REntry,RHashMap};

let mut map=RHashMap::<u32,u32>::new();

map.insert(6,15);

match map.entry(6) {
    REntry::Occupied(entry)=>{
        assert_eq!(entry.get(),&15);
    }
    REntry::Vacant(_)=>unreachable!(),
};

pub fn get_mut(&mut self) -> &mut V[src]

Gets a mutable reference to the value in the entry. To borrow with the lifetime of the map,use ROccupiedEntry::into_mut.

Example

use abi_stable::std_types::map::{REntry,RHashMap};

let mut map=RHashMap::<u32,u32>::new();

map.insert(6,15);

match map.entry(6) {
    REntry::Occupied(mut entry)=>{
        assert_eq!(entry.get_mut(),&mut 15);
    }
    REntry::Vacant(_)=>unreachable!(),
};

pub fn into_mut(self) -> &'a mut V[src]

Gets a mutable reference to the value in the entry, that borrows with the lifetime of the map instead of borrowing from this ROccupiedEntry.

Example

use abi_stable::std_types::map::{REntry,RHashMap};

let mut map=RHashMap::<String,u32>::new();

map.insert("baz".into(),0xDEAD);

match map.entry("baz".into()) {
    REntry::Occupied(entry)=>{
        assert_eq!(entry.into_mut(),&mut 0xDEAD);
    }
    REntry::Vacant(_)=>unreachable!(),
};

pub fn insert(&mut self, value: V) -> V[src]

Replaces the current value of the entry with value,returning the previous value.

Example

use abi_stable::std_types::map::{REntry,RHashMap};

let mut map=RHashMap::<String,u32>::new();

map.insert("baz".into(),0xD00D);

match map.entry("baz".into()) {
    REntry::Occupied(mut entry)=>{
        assert_eq!(entry.insert(0xDEAD),0xD00D);
    }
    REntry::Vacant(_)=>{
        unreachable!();
    }
}

assert_eq!( map.get("baz"), Some(&0xDEAD));

pub fn remove(self) -> V[src]

Removes the entry from the map,returns the value.

Example

use abi_stable::std_types::map::{REntry,RHashMap};

let mut map=RHashMap::<String,u32>::new();

map.insert("baz".into(),0xDEAD);

match map.entry("baz".into()) {
    REntry::Occupied(entry)=>{
        assert_eq!(entry.remove(),0xDEAD);
    }
    REntry::Vacant(_)=>{
        unreachable!();
    }
}

assert!( ! map.contains_key("baz") );

Trait Implementations

impl<K, V, '_> Debug for ROccupiedEntry<'_, K, V> where
    K: Debug,
    V: Debug
[src]

impl<'a, K, V> Drop for ROccupiedEntry<'a, K, V>[src]

impl<'a, K, V> GetStaticEquivalent_ for ROccupiedEntry<'a, K, V> where
    K: __StableAbi,
    V: __StableAbi,
    K: 'a,
    V: 'a, 
[src]

type StaticEquivalent = _static_ROccupiedEntry<'static, __GetStaticEquivalent<K>, __GetStaticEquivalent<V>>

impl<'a, K, V> StableAbi for ROccupiedEntry<'a, K, V> where
    K: __StableAbi,
    V: __StableAbi,
    K: 'a,
    V: 'a, 
[src]

type IsNonZeroType = False

Whether this type has a single invalid bit-pattern. Read more

Auto Trait Implementations

impl<'a, K, V> RefUnwindSafe for ROccupiedEntry<'a, K, V> where
    K: RefUnwindSafe,
    V: RefUnwindSafe

impl<'a, K, V> Send for ROccupiedEntry<'a, K, V> where
    K: Send,
    V: Send

impl<'a, K, V> Sync for ROccupiedEntry<'a, K, V> where
    K: Sync,
    V: Sync

impl<'a, K, V> Unpin for ROccupiedEntry<'a, K, V> where
    K: Unpin

impl<'a, K, V> !UnwindSafe for ROccupiedEntry<'a, K, V>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> GetWithMetadata for T[src]

type ForSelf = WithMetadata_<T, T>

This is always WithMetadata_<Self, Self>

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> SelfOps for T where
    T: ?Sized
[src]

impl<This> TransmuteElement for This where
    This: ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The error type returned when the conversion fails.

impl<T> TypeIdentity for T where
    T: ?Sized
[src]

type Type = T

The same type as Self. Read more