Skip to main content

Props

Struct Props 

Source
pub struct Props { /* private fields */ }
Expand description

The properties of a composed view, read inside its body.

Indices are the order the properties were added. Reading the wrong type at an index is a programming error the same way an out-of-range index is, and is caught the same way — by an assertion, not by a fault inside SwiftUI.

Implementations§

Source§

impl Props

Source

pub fn state<T: StateValue + Default>(&self, prop: StateProp<T>) -> T

The @State at index i.

Returns T’s default before SwiftUI has installed the property — the box is the last word of a State<V>, and a zero one means reading would fault rather than answer.

Source

pub fn stored<T: StoredValue>(&self, prop: StoredProp<T>) -> T

The @AppStorage at index i.

Source

pub fn focus(&self, prop: FocusProp) -> bool

Whether the @FocusState at index i currently has focus.

Source

pub fn focus_projection(&self, prop: FocusProp) -> [u64; 3]

The three words .focused(_:) wants, for the @FocusState at index i. Pass it to crate::views::focused_on on the field it belongs to.

Source

pub fn env<K: EnvKey>(&self, prop: EnvProp<K>) -> K::Value

The @Environment value at index i.

Auto Trait Implementations§

§

impl !Send for Props

§

impl !Sync for Props

§

impl Freeze for Props

§

impl RefUnwindSafe for Props

§

impl Unpin for Props

§

impl UnsafeUnpin for Props

§

impl UnwindSafe for Props

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.