4 releases
0.2.1 | Oct 4, 2024 |
---|---|
0.2.0 | Oct 4, 2024 |
0.1.1 | Nov 14, 2023 |
0.1.0 | Nov 8, 2023 |
#766 in Rust patterns
2,822 downloads per month
27KB
492 lines
Type Toppings
Opinionated collection of utility extensions for several of Rust's standard types, including:
Result
Iterator
futures::Steam
Documentation
https://docs.rs/type-toppings/latest/type_toppings/
Example
# Cargo.toml
[dependencies]
type-toppings = { version = "0.2", features = ["iterator"] }
use type_toppings::IteratorExt;
// Map only the Some values in an iterator of Option<T>:
let data: Vec<_> = vec![Some(1), None, Some(3)]
.into_iter()
.map_opt(|x| x * 2)
.collect();
assert_eq!(data, vec![Some(2), None, Some(6)]);
lib.rs
:
Type Toppings: Extensions for Standard Rust Types
Opinionated collection of utility extensions for several of Rust's standard types, including:
Result
Iterator
futures::Steam
Examples:
#[cfg(feature = "iterator")]
{
use type_toppings::IteratorExt;
// Map only the Some values in an iterator of Option<T>:
let data: Vec<_> = vec![Some(1), None, Some(3)]
.into_iter()
.map_opt(|x| x * 2)
.collect();
assert_eq!(data, vec![Some(2), None, Some(6)]);
}
For more detailed examples, see the documentation for each trait and method.
Dependencies
~140KB