An open API service indexing awesome lists of open source software.

https://github.com/coolreader18/some-mut

some-mut
https://github.com/coolreader18/some-mut

Last synced: 5 months ago
JSON representation

some-mut

Awesome Lists containing this project

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`:

```rust
// for a theoretical `StreamExt::forward()`/`SinkExt::send_all()` implementation:
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll> {
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](LICENSE) file for more details.