infinite-stream

Crates.ioinfinite-stream
lib.rsinfinite-stream
version0.1.0
created_at2025-06-16 11:28:53.128012+00
updated_at2025-06-16 11:28:53.128012+00
descriptionStreams (asynchronous iterators) that always keep yielding items (or panic, or become pending forever)
homepage
repositoryhttps://github.com/fenhl/infinite-stream
max_upload_size
id1714172
size28,811
Fenhl (fenhl)

documentation

README

infinite-stream is a Rust library for streams (asynchronous iterators) that always keep yielding items (or panic, or become pending forever). This means that the return type of the next future is Self::Item instead of Option<Self::Item>, for example, which lets you skip handling the None case.

Besides manually implementing the InfiniteStream trait, this crate currently offers the following ways to construct an infinite stream:

  • An expect extension method on regular (possibly finite) streams, which returns a wrapper stream that panics if None is yielded from the inner stream.
  • A pending function which returns an infinite stream that never yields any items, and a chain_pending method on regular streams which becomes pending after the inner stream is exhausted.
  • The functions unfold and try_unfold which are similar to the ones for regular streams.

This crate's implementation is heavily based on the implementation of the Stream trait and related helpers from the futures crate. However, this crate is in early stages of development and doesn't offer equivalents for most of the helpers from futures yet. Pull requests are welcome.

Commit count: 11

cargo fmt