pub struct Ref<T> { /* private fields */ }Expand description
Mutable, non-reactive reference container persisted across component re-renders (React useRef).
Mutating a Ref never marks the reactive graph dirty or triggers a re-render.
Implementations§
Source§impl<T> Ref<T>where
T: 'static,
impl<T> Ref<T>where
T: 'static,
pub fn new(initial: T) -> Ref<T>
pub fn get(&self) -> Twhere
T: Clone,
pub fn set(&self, value: T)
pub fn replace(&self, value: T) -> T
pub fn borrow(&self) -> Ref<'_, T>
pub fn borrow_mut(&self) -> RefMut<'_, T>
pub fn with<R>(&self, f: impl FnOnce(&T) -> R) -> R
pub fn with_mut<R>(&self, f: impl FnOnce(&mut T) -> R) -> R
Trait Implementations§
Auto Trait Implementations§
impl<T> !RefUnwindSafe for Ref<T>
impl<T> !Send for Ref<T>
impl<T> !Sync for Ref<T>
impl<T> !UnwindSafe for Ref<T>
impl<T> Forget for Ref<T>
impl<T> Freeze for Ref<T>
impl<T> Move for Ref<T>
impl<T> Unpin for Ref<T>
impl<T> UnsafeUnpin for Ref<T>
Blanket Implementations§
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