single

Crates.iosingle
lib.rssingle
version1.0.1
sourcesrc
created_at2017-06-08 05:18:36.999911
updated_at2022-07-08 18:23:33.052871
descriptionDeprecated poor-man's version of Itertools::at_most_one
homepage
repositoryhttps://github.com/CAD97/rust-single
max_upload_size
id18196
size10,254
Christopher Durham (CAD97)

documentation

README

This crate is deprecated.

Use Itertools::at_most_one instead, which provides equivalent functionality in a better fashion.


Single

Build Status crates.io downloads version downloads issues open

This crate provides the Single trait for extracting the element from a single-element iterator.

License

You may use this crate under the MIT license or the Apache License 2.0 at your discretion.

Trait single::Single

pub trait Single: Iterator {
    fn single(self) -> Result<Self::Item, Error>;
}

Required Methods

fn single(self) -> Result<Self::Item, Error>

Get the single element from a single-element iterator.

Examples

assert_eq!(iter::empty::<i32>().single(), Err(single::Error::NoElements));
assert_eq!(iter::once(0).single(), Ok(0));
assert_eq!(iter::repeat(0).single(), Err(single::Error::MultipleElements));

Implementors

impl<I: Iterator> Single for I {}
Commit count: 32

cargo fmt