Skip to main content

Nextable

Trait Nextable 

Source
pub trait Nextable {
    // Required methods
    fn current_index(&self) -> Option<usize>;
    fn dirs(&self) -> &Dirs;
    fn next_with(&self, nexter: NexterType, step: i32) -> Option<Dir<'_>>;

    // Provided method
    fn next(&self, nexter: NexterType) -> Option<Dir<'_>> { ... }
}

Required Methods§

Source

fn current_index(&self) -> Option<usize>

The index of the current directory in the list.

None means that the current directory is unknown; it is not in the list. Such a position is treated as the one before the first directory, hence, NexterType::Next finds the first directory from it, and NexterType::Previous and NexterType::Keep find nothing.

§Examples
use sibling::factory::DirsFactory;
use sibling::{NexterType, Nextable};

// no directory is given as the current one.
let dirs = DirsFactory::create("testdata/basic").expect("Failed to create Dirs");

assert!(dirs.current_index().is_none());
assert!(dirs.next(NexterType::Next).is_some());     // the first directory
assert!(dirs.next(NexterType::Previous).is_none()); // nothing is before it
assert!(dirs.next(NexterType::Keep).is_none());     // nothing to keep
Source

fn dirs(&self) -> &Dirs

Source

fn next_with(&self, nexter: NexterType, step: i32) -> Option<Dir<'_>>

Get the next directory using the given NexterType and step.

Provided Methods§

Source

fn next(&self, nexter: NexterType) -> Option<Dir<'_>>

Get the next directory using the given NexterType.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§