Crates.io | percolate |
lib.rs | percolate |
version | 0.0.3 |
source | src |
created_at | 2021-05-28 22:38:38.635151 |
updated_at | 2021-06-02 23:22:22.239478 |
description | Yet another async utility library. |
homepage | https://github.com/Tamschi/percolate/tree/v0.0.3 |
repository | https://github.com/Tamschi/percolate |
max_upload_size | |
id | 403326 |
size | 83,193 |
Yet another async utility library.
Note: The API will likely contain incomplete permutations during these first
0.0.x
versions.I mainly work on this crate as I need it for other projects of mine, but feel free to file an issue if you'd like to see a particular feature.
Please use cargo-edit to always add the latest version of this library:
cargo add percolate
use ergo_pin::ergo_pin;
use percolate::projection::{AsyncMut, IntoProjectionMut, ProjectionMut};
use pollster::block_on;
use tap::Conv;
#[ergo_pin]
async fn project<A, B, X>(value: A, projection: impl IntoProjectionMut<A, B, X>) -> B {
pin!(
projection.into_projection_mut() // impl ProjectionMut<A, B>
) // Pin<&mut impl ProjectionMut<A, B>>
.project(value) // PinHandleMut<dyn Future<B>>
.await // B
}
assert_eq!(block_on(project(1, |x: u8| x + 1)), 2);
assert_eq!(
block_on(project(
1,
// Type inference doesn't understand this on its own (yet), unfortunately.
// We can instead pass the projection pre-converted.
(|x| async move { x + 1 }).conv::<AsyncMut<_, _, _, _>>()),
),
2,
);
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
percolate
strictly follows Semantic Versioning 2.0.0 with the following exceptions:
This includes the Rust version requirement specified above.
Earlier Rust versions may be compatible, but this can change with minor or patch releases.
Which versions are affected by features and patches can be determined from the respective headings in CHANGELOG.md.