Crates.io | some-mut |
lib.rs | some-mut |
version | 0.1.2 |
source | src |
created_at | 2023-04-14 16:46:47.327857 |
updated_at | 2023-04-14 17:17:48.675099 |
description | A utility library for deferring the take()ing of an Option |
homepage | |
repository | https://github.com/coolreader18/some-mut |
max_upload_size | |
id | 839298 |
size | 7,397 |
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())?;
}
// ...
}
This project is licensed under the MIT license. Please see the LICENSE file for more details.