Skip to main content

Lazy

Struct Lazy 

Source
pub struct Lazy<V, F> { /* private fields */ }
Expand description

A lazy-initialized view.

The view is only initialized when polled for a grant.

Implementations§

Source§

impl<V, F> Lazy<V, F>

Source

pub fn new(init: F) -> Self

Create a new lazy view.

Source

pub fn into_inner(self) -> Option<V>

Return the inner type, if it has been initialized.

Source§

impl<V> Lazy<V, Box<dyn FnOnce() -> V>>

Source

pub fn new_boxed(init: impl FnOnce() -> V + 'static) -> Self

Available on crate features std only.

Create a new lazy view with a boxed initialization function.

Trait Implementations§

Source§

impl<V: Clone, F: Clone> Clone for Lazy<V, F>

Source§

fn clone(&self) -> Lazy<V, F>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<V: Debug, F: Debug> Debug for Lazy<V, F>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<V: Hash, F: Hash> Hash for Lazy<V, F>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<V, F> View for Lazy<V, F>
where V: View, F: FnOnce() -> V,

Source§

type Item = <V as View>::Item

The streamed type.
Source§

type Error = <V as View>::Error

The error produced by poll_grant.
Source§

fn view(&self) -> &[Self::Item]

Obtain the current view of the stream. Read more
Source§

fn poll_grant( self: Pin<&mut Self>, cx: &mut Context<'_>, count: usize, ) -> Poll<Result<(), Self::Error>>

Attempt to obtain a view of at least count elements. Read more
Source§

fn release(&mut self, count: usize)

Attempt to advance past the first count elements in the current view. Read more
Source§

fn grant(&mut self, count: usize) -> Grant<'_, Self>

Create a future that obtains a view of at least count elements. Read more
Source§

fn blocking_grant(&mut self, count: usize) -> Result<(), Self::Error>

Obtains a view of at least count elements, blocking the current thread. Read more
Source§

fn map_error<E, F>(self, f: F) -> MapError<Self, E, F>
where F: Fn(Self::Error) -> E,

Maps this view to a new view producing error E.
Source§

impl<V, F> ViewMut for Lazy<V, F>
where V: ViewMut, F: FnOnce() -> V,

Source§

fn view_mut(&mut self) -> &mut [Self::Item]

Obtain the current mutable view of the stream. Read more
Source§

impl<V: Copy, F: Copy> Copy for Lazy<V, F>

Source§

impl<'pin, V, F> Unpin for Lazy<V, F>
where PinnedFieldsOf<__Lazy<'pin, V, F>>: Unpin,

Auto Trait Implementations§

§

impl<V, F> Freeze for Lazy<V, F>
where V: Freeze, F: Freeze,

§

impl<V, F> RefUnwindSafe for Lazy<V, F>

§

impl<V, F> Send for Lazy<V, F>
where V: Send, F: Send,

§

impl<V, F> Sync for Lazy<V, F>
where V: Sync, F: Sync,

§

impl<V, F> UnsafeUnpin for Lazy<V, F>
where V: UnsafeUnpin, F: UnsafeUnpin,

§

impl<V, F> UnwindSafe for Lazy<V, F>
where V: UnwindSafe, F: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.