pub struct Binding<T> { /* private fields */ }Expand description
A read/write handle to a value owned elsewhere (SwiftUI’s @Binding).
Components that edit a value (a toggle, a text field) take a Binding so the
caller decides where the value lives. Reads are tracked like the underlying
state’s reads.
Implementations§
Source§impl<T> Binding<T>where
T: 'static,
impl<T> Binding<T>where
T: 'static,
Sourcepub fn new(
get: impl Fn() -> T + 'static,
set: impl Fn(T) + 'static,
) -> Binding<T>
pub fn new( get: impl Fn() -> T + 'static, set: impl Fn(T) + 'static, ) -> Binding<T>
Creates a binding from a getter and a setter.
Sourcepub fn constant(value: T) -> Binding<T>where
T: Clone,
pub fn constant(value: T) -> Binding<T>where
T: Clone,
A binding that always reads value and ignores writes; useful in previews and tests.
Trait Implementations§
Auto Trait Implementations§
impl<T> !RefUnwindSafe for Binding<T>
impl<T> !Send for Binding<T>
impl<T> !Sync for Binding<T>
impl<T> !UnwindSafe for Binding<T>
impl<T> Freeze for Binding<T>
impl<T> Unpin for Binding<T>
impl<T> UnsafeUnpin for Binding<T>
Blanket Implementations§
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
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