Crates.io | list-fn |
lib.rs | list-fn |
version | 0.20.1 |
source | src |
created_at | 2021-04-07 18:30:37.460473 |
updated_at | 2023-10-27 19:19:09.596768 |
description | A generic lazy list |
homepage | |
repository | https://github.com/natfoam/lib |
max_upload_size | |
id | 380507 |
size | 25,683 |
A generic lazy list. It's an immutable iterator with continuations.
The lazy list can be used as an immutable alternative to the standard Rust iterator.
Any List<End = Self>
is an iterator. Any &mut Iterator
is a List<End = Self>
.
See also Generators.
FlatScan
. An order of items is important.
FilterScan
Scan
Fold
FlatMap
. An order of items is not important.
Map
Filter
Flatten
trait Iterator {
type Item;
fn next(&mut self) -> Option<Self::Item>;
}
trait IteratorReturn: Iterator {
type Return;
fn return(&mut self) -> Return;
}
trait Generator {
type Yield;
type Return;
fn resume(&mut self) -> GeneratorState<Self::Yield, Self::Return>;
}
enum GeneratorState<Y, R> {
Yielded(Y),
Complete(R),
}
trait List {
type Yield;
type Return;
fn resume(self) -> ListState<Self>;
}
enum ListState<L: List> {
Yielded(L::Yield, L),
Return(L::Return),
}
trait FlatScan {
type InputYield;
type InputReturn;
type OutputYield;
type OutputReturn;
fn map_yield(self, input_yield: Self::InputYield) -> impl List<Yield = Self::OutputYield, Return = Self>;
fn map_return(self, input_return: Self::InputReturn) -> impl List<Yield = Self::OutputYield, Return = OutputReturn>;
}
trait FlatScan {
type InputYield;
type InputReturn;
type OutputYield;
type OutputReturn;
fn map_yield(&mut self, input_yield: Self::InputYield) -> impl Iterator<Item = Self::OutputYield>;
fn map_return(&mut self, input_return: Self::InputReturn) ->
impl Generator<Item = Self::OutputYield, Return = Self::OutputReturn>;
}
trait FlatScan {
type InputYield;
type InputReturn;
type OutputYield;
type OutputReturn;
fn map_yield(&mut self, input_yield: Self::InputYield) -> impl Iterator<Item = Self::OutputYield>;
fn map_return(&mut self, input_return: Self::InputReturn) ->
impl Iterator<Item = Self::OutputYield> + IteratorReturn<Return = Self::OutputReturn>;
}