# Single
[ 
](https://travis-ci.org/CAD97/rust-single)
[ 
](https://crates.io/crates/single)
[ 
](https://crates.io/crates/single)
[ 
](https://crates.io/crates/single)
[ 
](https://github.com/CAD97/rust-single/issues)
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
```rust
pub trait Single {
fn single(self) -> Result<Self::Item, Error>;
}
```
### Required Methods
<dl>
<dt><code>fn single(self) -> Result<Self::Item, Error></code>
<dd>
<p>Get the single element from a single-element iterator.
<h4>Examples</h4>
```rust
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));
```
</dl>
### Implementors
```rust
impl<I: Iterator> Single for I {}
```