https://github.com/coolreader18/some-mut
some-mut
https://github.com/coolreader18/some-mut
Last synced: 5 months ago
JSON representation
some-mut
- Host: GitHub
- URL: https://github.com/coolreader18/some-mut
- Owner: coolreader18
- License: mit
- Created: 2023-04-14T16:44:48.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-04-14T17:17:48.000Z (almost 3 years ago)
- Last Synced: 2025-06-23T22:15:41.416Z (7 months ago)
- Language: Rust
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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.