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]

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());

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());

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());

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());

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 Clone for Status
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Debug for Status
[src]

Formats the value using the given formatter. Read more

impl PartialEq for Status
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Eq for Status
[src]

Auto Trait Implementations

impl Send for Status

impl Sync for Status