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

#823 in Rust patterns

Download history 1/week @ 2024-09-18 6/week @ 2024-09-25 467/week @ 2024-10-02 473/week @ 2024-10-09 824/week @ 2024-10-16 708/week @ 2024-10-23 646/week @ 2024-10-30 288/week @ 2024-11-06 476/week @ 2024-11-13 367/week @ 2024-11-20 189/week @ 2024-11-27 203/week @ 2024-12-04 160/week @ 2024-12-11 143/week @ 2024-12-18 3/week @ 2024-12-25

529 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

~135KB