mcoffin-tuple-ext

Crates.iomcoffin-tuple-ext
lib.rsmcoffin-tuple-ext
version0.1.0
sourcesrc
created_at2020-11-17 16:27:07.336302
updated_at2020-11-17 16:27:07.336302
descriptionSimple option extension trait for dealing with tuples
homepage
repository
max_upload_size
id313328
size6,783
Publish (github:tower-rs:publish)

documentation

https://docs.rs/mcoffin-tuple-ext

README

mcoffin-tuple-ext

Simple extension trait for Option for working with tupleized results.

Example

extern crate mcoffin_tuple_ext;
use mcoffin_tuple_ext::OptionExt;

fn main() {
    let first = Some(1usize);
    assert_eq!(first.and_tup(first), Some((1usize, 1usize)));
    assert_eq!(first.and_tup(Some(2usize)), Some((1usize, 2usize)));
    assert_eq!(first.and_tup::<usize>(None), None);

    let v = first.and_then_tup(|_| Some("foo".to_string()));
    assert!(v.is_some());
    let (fst, snd) = v.unwrap();
    assert_eq!(fst, 1);
    assert_eq!(&snd, "foo");
}
Commit count: 0

cargo fmt