Skip to content

Commit

Permalink
Add get_history_const() function
Browse files Browse the repository at this point in the history
This returns an immutable reference to the history object. Callers may
need only read access to the history, for example when getting an entry
by index. While callers could use get_history(), which returns a mutable
reference, this causes all callers to get a mutable reference to Editor,
which they may or may not have.
  • Loading branch information
rgardner committed Jan 19, 2017
1 parent ec773db commit f536c96
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1105,10 +1105,14 @@ impl<C: Completer> Editor<C> {
pub fn clear_history(&mut self) {
self.history.clear()
}
/// Return a reference to the history object.
/// Return a mutable reference to the history object.
pub fn get_history(&mut self) -> &mut History {
&mut self.history
}
/// Return an immutable reference to the history object.
pub fn get_history_const(&self) -> &History {
&self.history
}

/// Register a callback function to be called for tab-completion.
pub fn set_completer(&mut self, completer: Option<C>) {
Expand Down

0 comments on commit f536c96

Please sign in to comment.