Struct splop::Status [−][src]
pub struct Status { /* fields omitted */ }
The status of an item from an iterator (e.g. "is this the first item?").
Methods
impl Status
[src]
impl Status
pub fn is_first(&self) -> bool
[src]
pub fn is_first(&self) -> bool
Returns true
if this is the first item of the iterator.
Note that an item might simultaniously be the first and last item (if
the iterator only contains one item). To check if the item is the first
and and not the last, use Status::is_first_only
.
Example
use splop::IterStatusExt; let v: Vec<_> = (0..4) .with_status() .map(|(i, status)| (i, status.is_first())) .collect(); assert_eq!(v, [ (0, true), (1, false), (2, false), (3, false), ]);
If there is only one element, this function returns true
, as does
is_last
:
use splop::IterStatusExt; let (_, status) = [27].iter() .with_status() .next() .unwrap(); assert!(status.is_first()); assert!(status.is_last());
pub fn is_first_only(&self) -> bool
[src]
pub fn is_first_only(&self) -> bool
Returns true
if this is the first item and it's not the only item in
the iterator.
Example
use splop::IterStatusExt; let v: Vec<_> = (0..4) .with_status() .map(|(i, status)| (i, status.is_first_only())) .collect(); assert_eq!(v, [ (0, true), (1, false), (2, false), (3, false), ]);
If there is only one element, this function returns false
:
use splop::IterStatusExt; let (_, status) = [27].iter() .with_status() .next() .unwrap(); assert!(!status.is_first_only());
pub fn is_last(&self) -> bool
[src]
pub fn is_last(&self) -> bool
Returns true
if this is the last item of the iterator.
Note that an item might simultaniously be the last and first item (if
the iterator only contains one item). To check if the item is the last
and and not the first, use Status::is_last_only
.
Example
use splop::IterStatusExt; let v: Vec<_> = (0..4) .with_status() .map(|(i, status)| (i, status.is_last())) .collect(); assert_eq!(v, [ (0, false), (1, false), (2, false), (3, true), ]);
If there is only one element, this function returns true
, as does
is_first
:
use splop::IterStatusExt; let (_, status) = [27].iter() .with_status() .next() .unwrap(); assert!(status.is_first()); assert!(status.is_last());
pub fn is_last_only(&self) -> bool
[src]
pub fn is_last_only(&self) -> bool
Returns true
if this is the last item and it's not the only item in
the iterator.
Example
use splop::IterStatusExt; let v: Vec<_> = (0..4) .with_status() .map(|(i, status)| (i, status.is_last_only())) .collect(); assert_eq!(v, [ (0, false), (1, false), (2, false), (3, true), ]);
If there is only one element, this function returns false
:
use splop::IterStatusExt; let (_, status) = [27].iter() .with_status() .next() .unwrap(); assert!(!status.is_last_only());
pub fn is_in_between(&self) -> bool
[src]
pub fn is_in_between(&self) -> bool
Returns true
if this is neither the first nor the last item.
Example
use splop::IterStatusExt; let v: Vec<_> = (0..4) .with_status() .map(|(i, status)| (i, status.is_in_between())) .collect(); assert_eq!(v, [ (0, false), (1, true), (2, true), (3, false), ]);
Trait Implementations
impl Copy for Status
[src]
impl Copy for Status
impl Clone for Status
[src]
impl Clone for Status
fn clone(&self) -> Status
[src]
fn clone(&self) -> Status
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Debug for Status
[src]
impl Debug for Status
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl PartialEq for Status
[src]
impl PartialEq for Status
fn eq(&self, other: &Status) -> bool
[src]
fn eq(&self, other: &Status) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Status) -> bool
[src]
fn ne(&self, other: &Status) -> bool
This method tests for !=
.
impl Eq for Status
[src]
impl Eq for Status