some-mut

Crates.iosome-mut
lib.rssome-mut
version0.1.2
sourcesrc
created_at2023-04-14 16:46:47.327857
updated_at2023-04-14 17:17:48.675099
descriptionA utility library for deferring the take()ing of an Option
homepage
repositoryhttps://github.com/coolreader18/some-mut
max_upload_size
id839298
size7,397
Noa (coolreader18)

documentation

README

some-mut

A utility library that mainly lets you access a Some and then take() it infallibly.

Useful, for example, in a Future implementation, when you might re-enter into a function multiple times and so can't take() until a sub-future is Ready:

// for a theoretical `StreamExt::forward()`/`SinkExt::send_all()` implementation:
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Error>> {
    if let Some(buffered_item) = self.buffered_item.some_mut() {
        ready!(self.sink.poll_ready(cx))?;
        self.sink.start_send(buffered_item.take())?;
    }
    // ...
}

License

This project is licensed under the MIT license. Please see the LICENSE file for more details.

Commit count: 3

cargo fmt