Skip to main content

Latest

Struct Latest 

Source
pub struct Latest<T>(/* private fields */);
Expand description

Keeps only the newest item: each item the source pushes replaces the one waiting to be polled. This is onBackpressureLatest of other ReactiveX stacks.

The memory cost is one item whatever the pace of the source, at the price of skipping the items the consumer was too slow to see — right for a stream of states, where only the current one matters, and wrong for a stream of events.

Implementations§

Source§

impl<T> Latest<T>

Source

pub fn new() -> Self

Trait Implementations§

Source§

impl<T> Debug for Latest<T>
where Option<T>: Debug,

Source§

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

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

impl<T> Default for Latest<T>
where Option<T>: Default,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<T> StreamBuffer<T> for Latest<T>

Source§

type Item = T

What the stream yields.
Source§

fn push(&mut self, item: T) -> Option<T>

Stores an item the source pushed. Read more
Source§

fn pop(&mut self) -> Option<T>

Takes the next item to yield, or None when the stream has to wait for the source.

Auto Trait Implementations§

§

impl<T> Freeze for Latest<T>
where Option<T>: Freeze,

§

impl<T> RefUnwindSafe for Latest<T>

§

impl<T> Send for Latest<T>
where Option<T>: Send,

§

impl<T> Sync for Latest<T>
where Option<T>: Sync,

§

impl<T> Unpin for Latest<T>
where Option<T>: Unpin,

§

impl<T> UnsafeUnpin for Latest<T>
where Option<T>: UnsafeUnpin,

§

impl<T> UnwindSafe for Latest<T>
where Option<T>: 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> 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> MaybeSend for T
where T: Send,

Source§

impl<T> MaybeSync for T
where T: Sync,

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.