Struct rustyline::history::History
[−]
[src]
pub struct History { /* fields omitted */ }
Current state of the history.
Methods
impl History
[src]
fn new() -> History
fn with_config(config: Config) -> History
fn get(&self, index: usize) -> Option<&String>
Return the history entry at position index
, starting from 0.
fn last(&self) -> Option<&String>
Return the last history entry (i.e. previous command)
fn add<S: AsRef<str> + Into<String>>(&mut self, line: S) -> bool
Add a new entry in the history.
fn len(&self) -> usize
Returns the number of entries in the history.
fn is_empty(&self) -> bool
Returns true if the history has no entry.
fn set_max_len(&mut self, len: usize)
Set the maximum length for the history. This function can be called even
if there is already some history, the function will make sure to retain
just the latest len
elements if the new history length value is smaller
than the amount of items already inside the history.
fn save<P: AsRef<Path> + ?Sized>(&self, path: &P) -> Result<()>
Save the history in the specified file.
fn load<P: AsRef<Path> + ?Sized>(&mut self, path: &P) -> Result<()>
fn clear(&mut self)
Clear history
fn search(&self, term: &str, start: usize, dir: Direction) -> Option<usize>
Search history (start position inclusive [0, len-1])
Return the absolute index of the nearest history entry that matches term
.
Return None if no entry contains term
between [start, len -1] for forward search
or between [0, start] for reverse search.
fn iter(&self) -> Iter
Return a forward iterator.
Trait Implementations
impl Index<usize> for History
[src]
type Output = String
The returned type after indexing
fn index(&self, index: usize) -> &String
The method for the indexing (container[index]
) operation