Struct consecuit::hooks::Reference[][src]

pub struct Reference<T: Default + 'static> { /* fields omitted */ }
Expand description

A reference with interior mutability. Somewhat like RefCell. Returned by use_ref.

This can be read from and written to anytime. Writing to it does not trigger rerender.

This is often not neccessary. Use super::use_state() instead.

Implementations

Run the given closure with a borrow of the data inside the Reference as argument.

Returns a Result with the Ok variant being the return value of your closure.

The error variant is SubtreeUnmountedError. This error is thrown if this function is called when the subtree where the use_ref this comes from had been unmounted.

Run the given closure with a mutable borrow of the data inside the Reference as argument.

Returns a Result with the Ok variant being the return value of your closure.

The error variant is SubtreeUnmountedError. This error is thrown if this function is called when the subtree where the use_ref this comes from had been unmounted.

Set the value in the Ref to the given value.

This does not trigger a rerender.

The error variant is SubtreeUnmountedError. This error is thrown if this function is called when the subtree where the use_ref this comes from had been unmounted.

Return a clone of the value inside the Ref.

The Ok variant is said value.

The error variant is SubtreeUnmountedError. This error is thrown if this function is called when the subtree where the use_ref this comes from had been unmounted.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.