Trait pinus::prelude::PinnedPineMapEmplace [−][src]
pub unsafe trait PinnedPineMapEmplace<K: Ord, V: ?Sized, W>: PinnedPineMap<K, V> where
Self::Unpinned: UnpinnedPineMapEmplace<K, V, W>, {
fn try_emplace_with<F: for<'a> FnOnce(&K, Pin<&'a mut MaybeUninit<W>>) -> Result<Pin<&'a mut V>, E>, E>(
&self,
key: K,
value_factory: F
) -> Result<Fine<Pin<&V>, (K, F)>, E> { ... }
fn try_emplace_with_unpinned<'a, F: for<'b> FnOnce(&K, &'b mut MaybeUninit<W>) -> Result<&'b mut V, E>, E>(
&'a self,
key: K,
value_factory: F
) -> Result<Fine<Pin<&'a V>, (K, F)>, E>
where
Self::Unpinned: 'a,
{ ... }
fn emplace_with<F: for<'a> FnOnce(&K, Pin<&'a mut MaybeUninit<W>>) -> Pin<&'a mut V>>(
&self,
key: K,
value_factory: F
) -> Fine<Pin<&V>, (K, F)> { ... }
fn emplace_with_unpinned<'a, F: for<'b> FnOnce(&K, &'b mut MaybeUninit<W>) -> &'b mut V>(
&'a self,
key: K,
value_factory: F
) -> Fine<Pin<&'a V>, (K, F)>
where
Self::Unpinned: 'a,
{ ... }
fn emplace(&self, key: K, value: W) -> Fine<Pin<&V>, (K, W)>
where
W: BorrowMut<V>,
{ ... }
fn try_emplace_with_mut<'a, F: for<'b> FnOnce(&K, Pin<&'b mut MaybeUninit<W>>) -> Result<Pin<&'b mut V>, E>, E>(
&'a mut self,
key: K,
value_factory: F
) -> Result<Fine<Pin<&'a mut V>, (K, F)>, E>
where
Self::Unpinned: 'a,
{ ... }
fn try_emplace_with_mut_unpinned<'a, F: for<'b> FnOnce(&K, &'b mut MaybeUninit<W>) -> Result<&'b mut V, E>, E>(
&'a mut self,
key: K,
value_factory: F
) -> Result<Fine<Pin<&'a mut V>, (K, F)>, E>
where
Self::Unpinned: 'a,
{ ... }
fn emplace_with_mut<'a, F: for<'b> FnOnce(&K, Pin<&'b mut MaybeUninit<W>>) -> Pin<&'b mut V>>(
&'a mut self,
key: K,
value_factory: F
) -> Fine<Pin<&'a mut V>, (K, F)>
where
Self::Unpinned: 'a,
{ ... }
fn emplace_with_mut_unpinned<'a, F: for<'b> FnOnce(&K, &'b mut MaybeUninit<W>) -> &'b mut V>(
&'a mut self,
key: K,
value_factory: F
) -> Fine<Pin<&'a mut V>, (K, F)>
where
Self::Unpinned: 'a,
{ ... }
fn emplace_mut<'a>(
&'a mut self,
key: K,
value: W
) -> Fine<Pin<&'a mut V>, (K, W)>
where
Self::Unpinned: 'a,
W: BorrowMut<V>,
{ ... }
}
Expand description
The pinned emplacement API.
Safety
Any implementors must ensure their UnpinnedPineMapEmplace
implementation would be valid if all V
alues were pinned.
If you MUST implement this yourself, pin this package to a specific minor version! New methods with default implementations may be added in any feature update.
Provided methods
Tries to emplace a new value produced by the given factory, but only if no such key exists yet.
In many cases, you’ll want to call
.try_emplace_with_unpinned(…)
instead, which can be (more easily) satisfied without usingunsafe
code in the callback.
Safety
Note that the Pin<&’a mut MaybeUninit
doesn’t imply a drop guarantee for W
,
but only that that entire allocation will remain untouched for 'a
.
Any resulting Pin<&'a V>
or Pin<&'a mut V>
will have
its Deref::Target
dropped in place (or leaked), however, as implied.
Errors
Outer error: Iff value_factory
fails.
Inner error: Iff an entry matching key
already exists.
Tries to emplace a new unpinned value produced by the given factory, but only if no such key exists yet, and then immediately pins it.
Errors
Outer error: Iff value_factory
fails.
Inner error: Iff an entry matching key
already exists.
Emplaces a new value produced by the given factory, but only if no such key exists yet.
In many cases, you’ll want to call
.emplace_with_unpinned(…)
instead, which can be (more easily) satisfied without usingunsafe
code in the callback.
Safety
Note that the Pin<&’a mut MaybeUninit
doesn’t imply a drop guarantee for W
,
but only that that entire allocation will remain untouched for 'a
.
Any resulting Pin<&'a V>
or Pin<&'a mut V>
will have
its Deref::Target
dropped in place (or leaked), however, as implied.
Errors
Iff an entry matching key
already exists.
Emplaces a new unpinned value produced by the given factory, but only if no such key exists yet, and then immediately pins it.
Errors
Iff an entry matching key
already exists.
Emplaces a new value, but only if no such key exists yet.
Safety
Note that there is no drop guarantee for W
(and that type will in fact not have its Drop::drop
called directly)!
Any resulting Pin<&'a V>
or Pin<&'a mut V>
will have
its Deref::Target
dropped in place (or leaked), however, as implied.
Errors
Iff an entry matching key
already exists.
Tries to emplace a new value produced by the given factory, but only if no such key exists yet.
In many cases, you’ll want to call
.try_emplace_with_mut_unpinned(…)
instead, which can be (more easily) satisfied without usingunsafe
code in the callback.
Safety
Note that the Pin<&’a mut MaybeUninit
doesn’t imply a drop guarantee for W
,
but only that that entire allocation will remain untouched for 'a
.
Any resulting Pin<&'a V>
or Pin<&'a mut V>
will have
its Deref::Target
dropped in place (or leaked), however, as implied.
Errors
Outer error: Iff value_factory
fails.
Inner error: Iff an entry matching key
already exists.
Tries to emplace a new unpinned value produced by the given factory, but only if no such key exists yet, and then immediately pins it.
Errors
Outer error: Iff value_factory
fails.
Inner error: Iff an entry matching key
already exists.
Emplaces a new value produced by the given factory, but only if no such key exists yet.
In many cases, you’ll want to call
.emplace_with_mut_unpinned(…)
instead, which can be (more easily) satisfied without usingunsafe
code in the callback.
Safety
Note that the Pin<&’a mut MaybeUninit
doesn’t imply a drop guarantee for W
,
but only that that entire allocation will remain untouched for 'a
.
Any resulting Pin<&'a V>
or Pin<&'a mut V>
will have
its Deref::Target
dropped in place (or leaked), however, as implied.
Errors
Iff an entry matching key
already exists.
Emplaces a new unpinned value produced by the given factory, but only if no such key exists yet, and then immediately pins it.
Errors
Iff an entry matching key
already exists.
Emplaces a new value, but only if no such key exists yet.
Safety
Note that there is no drop guarantee for W
(and that type will in fact not have its Drop::drop
called directly)!
Any resulting Pin<&'a V>
or Pin<&'a mut V>
will have
its Deref::Target
dropped in place (or leaked), however, as implied.
Errors
Iff an entry matching key
already exists.