Struct hooks::shared_state::SharedStateEq
source · pub struct SharedStateEq<T: PartialEq>(_);
Implementations§
pub fn new(initial_value: T) -> Self
pub fn inner(&self) -> &SharedState<T>
Trait Implementations§
§type Value = &'hook SharedStateEq<T>
type Value = &'hook SharedStateEq<T>
The output type of
Hook::use_hook
. Read moresource§fn replace_mut<F: FnOnce(&mut T) -> T>(&self, f: F) -> T
fn replace_mut<F: FnOnce(&mut T) -> T>(&self, f: F) -> T
Always notify the value is changed
because the caller can mutate the value inside f
.
To notify changes only when new_value != old_value
,
use replace_from_ref
or
self.inner().map_mut_and_notify_if()
instead.
fn get(&self) -> Twhere T: Copy,
fn get_cloned(&self) -> Twhere T: Clone,
fn set(&self, new_value: T)
source§fn replace_with<F: FnOnce(&T) -> T>(&self, f: F) -> T
fn replace_with<F: FnOnce(&T) -> T>(&self, f: F) -> T
The old value is returned.
fn map<R>(&self, f: impl FnOnce(&T) -> R) -> R
fn map_mut<R>(&self, f: impl FnOnce(&mut T) -> R) -> R
Auto Trait Implementations§
Blanket Implementations§
source§fn use_hook(&mut self) -> Self::Valuewhere
Self: Unpin,
fn use_hook(&mut self) -> Self::Valuewhere Self: Unpin,
A shortcut to call
Hook::use_hook
on Unpin hooks.fn next_value(&mut self) -> NextValue<'_, Self>where Self: Unpin,
fn into_values(self) -> Values<Self>where Self: Sized,
fn values(&mut self) -> Values<&mut Self>where Self: Unpin,
source§fn poll_next_update(&mut self, cx: &mut Context<'_>) -> Poll<bool>where
Self: Unpin,
fn poll_next_update(&mut self, cx: &mut Context<'_>) -> Poll<bool>where Self: Unpin,
A shortcut to call
HookPollNextUpdate::poll_next_update
on Unpin hooks.source§fn next_update(&mut self) -> NextUpdate<'_, Self>where
Self: Unpin,
fn next_update(&mut self) -> NextUpdate<'_, Self>where Self: Unpin,
Get a future which polls
HookPollNextUpdate::poll_next_update
.