Skip to main content

Sequence

Trait Sequence 

Source
pub trait Sequence: Send + Sync {
    // Required method
    fn next_item(&self, cx: &mut Cx) -> Result<Option<SequenceItem>>;

    // Provided methods
    fn close(&self, _cx: &mut Cx) -> Result<()> { ... }
    fn peek_item(&self, _cx: &mut Cx) -> Result<Option<SequenceItem>> { ... }
    fn is_done(&self, _cx: &mut Cx) -> Result<bool> { ... }
}
Expand description

Pull-based iteration protocol over runtime values.

Required Methods§

Source

fn next_item(&self, cx: &mut Cx) -> Result<Option<SequenceItem>>

Pulls the next item, or Ok(None) once exhausted.

Provided Methods§

Source

fn close(&self, _cx: &mut Cx) -> Result<()>

Releases resources backing the sequence; idempotent by default.

Source

fn peek_item(&self, _cx: &mut Cx) -> Result<Option<SequenceItem>>

Peeks the next item without consuming it; unsupported by default.

Source

fn is_done(&self, _cx: &mut Cx) -> Result<bool>

Whether the sequence is known to be exhausted; false by default.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§