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

Download history 17/week @ 2024-07-27 1/week @ 2024-08-03 4/week @ 2024-09-21 194/week @ 2024-09-28 437/week @ 2024-10-05 661/week @ 2024-10-12 821/week @ 2024-10-19 705/week @ 2024-10-26 588/week @ 2024-11-02

2,822 downloads per month

MIT license

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