some-mut 0.1.2

A utility library for deferring the take()ing of an Option
Documentation
  • Coverage
  • 100%
    7 out of 7 items documented2 out of 7 items with examples
  • Size
  • Source code size: 7.08 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.04 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • coolreader18/some-mut
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • coolreader18

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.