3 releases
0.0.3 | Jun 2, 2021 |
---|---|
0.0.2 | May 30, 2021 |
0.0.1 | May 28, 2021 |
#651 in #stream
61KB
1.5K
SLoC
percolate
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.
Installation
Please use cargo-edit to always add the latest version of this library:
cargo add percolate
Example
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,
);
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
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.
Code of Conduct
Changelog
Versioning
percolate
strictly follows Semantic Versioning 2.0.0 with the following exceptions:
- The minor version will not reset to 0 on major version changes (except for v1).
Consider it the global feature level. - The patch version will not reset to 0 on major or minor version changes (except for v0.1 and v1).
Consider it the global patch level.
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.
Dependencies
~1–1.5MB
~32K SLoC