pub struct LoopSyncCellMappedAccess<'cell, T, V = ()> { /* private fields */ }Expand description
Accessor for a LoopSyncCell, that will automatically write back any modifications to the value
on drop (unless disarmed with LoopSyncCellMappedAccess::consume) so the LoopSyncCell is “used
up”.
Unlike LoopSyncCellAccess, this contains an extra value, and lets you perform modifications to
it with the “context” of the loop cell accessor (which is mutable).
This provides a clean way to bundle an accessor and also bundle a data value, which should be processed with the accessor.
Implementations§
Source§impl<'cell, T, V> LoopSyncCellMappedAccess<'cell, T, V>
impl<'cell, T, V> LoopSyncCellMappedAccess<'cell, T, V>
Sourcepub fn map_loopcell_access<O>(
self,
f: impl FnOnce(&mut T, V) -> O,
) -> LoopSyncCellMappedAccess<'cell, T, O>
pub fn map_loopcell_access<O>( self, f: impl FnOnce(&mut T, V) -> O, ) -> LoopSyncCellMappedAccess<'cell, T, O>
Apply a function to the mapped value, to produce a new mapped value - but it also makes the inner loop cell value that we have access to available.
Sourcepub fn commit(self) -> V
pub fn commit(self) -> V
Commit the changes made to the LoopSyncCell through this accessor, making the LoopSyncCell
available to everyone once again with the new cell data, while also emitting the bundled value.
Sourcepub fn consume(self) -> (T, V)
pub fn consume(self) -> (T, V)
Consume the changes made to the LoopSyncCell through this accessor, making the LoopSyncCell
never have any more values. This returns the last value of the LoopSyncCell as modified by
this accessor, as well as the bundled value.
Sourcepub fn get_loopcell_value(&self) -> &T
pub fn get_loopcell_value(&self) -> &T
Get the value of the loopcell from the access
Sourcepub fn get_loopcell_value_mut(&mut self) -> &mut T
pub fn get_loopcell_value_mut(&mut self) -> &mut T
Get the value of the loopcell from the access, mutably.
Sourcepub fn get_value_mut(&mut self) -> &mut V
pub fn get_value_mut(&mut self) -> &mut V
Get the bundled value from the access, mutably.
Sourcepub fn unmap_access(self) -> (LoopSyncCellAccess<'cell, T>, V)
pub fn unmap_access(self) -> (LoopSyncCellAccess<'cell, T>, V)
Unpack the bundled value from the normal LoopSyncCellAccess