pub fn map<U, F>(&self, f: F) -> NonEmpty<U>
    where
        F: Fn(&T) -> U,
    {
        NonEmpty(f(&self.0), self.1.iter().map(f).collect())
    }
/// A structure preserving `map`. This is useful for when
/// we wish to keep the `NonEmpty` structure guaranteeing
/// that there is at least one element. Otherwise, we can
/// use `nonempty.iter().map(f)`.
///
/// # Example Use
///
/// ```
/// use nonempty::NonEmpty;
///
/// let non_empty = NonEmpty::from((1, vec![2, 3, 4, 5]));
///
/// let squares = non_empty.map(|i| i * i);
///
/// let expected = NonEmpty::from((1, vec![4, 9, 16, 25]));
///
/// assert_eq!(squares, expected);
/// ```
A structure preserving `map`. This is useful for when
we wish to keep the `NonEmpty` structure guaranteeing
that there is at least one element.
A structure preserving ` map ` . This is useful for when we wish to keep the ` NonEmpty ` structure guaranteeing that there is at least one element .
pub fn map<U, F>(&self, f: F) -> NonEmpty<U>
    where
        F: Fn(&T) -> U,
    {
        NonEmpty(f(&self.0), self.1.iter().map(f).collect())
    }
pub fn map < U , F > ( & self , f : F ) -> NonEmpty < U > where F : Fn ( & T ) -> U , { NonEmpty ( f ( & self . 0 ) , self . 1 . iter ( ) . map ( f ) . collect ( ) ) }
A structure preserving `map`.
A structure preserving ` map ` .
&self
f
F
&self
f
F
example use
```
use nonempty::NonEmpty.







assert_eq!(squares, expected);
```
` ` ` use nonempty :: NonEmpty . assert_eq! ( squares expected ) ; ` ` `