summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/custom_key_bindings.rs2
-rw-r--r--examples/example.rs2
-rw-r--r--src/hint.rs8
3 files changed, 10 insertions, 2 deletions
diff --git a/examples/custom_key_bindings.rs b/examples/custom_key_bindings.rs
index 3fa4519..78db874 100644
--- a/examples/custom_key_bindings.rs
+++ b/examples/custom_key_bindings.rs
@@ -87,7 +87,7 @@ impl ConditionalEventHandler for TabEventHandler {
fn main() -> Result<()> {
let mut rl = Editor::<MyHelper, DefaultHistory>::new()?;
- rl.set_helper(Some(MyHelper(HistoryHinter {})));
+ rl.set_helper(Some(MyHelper(HistoryHinter::new())));
let ceh = Box::new(CompleteHintHandler);
rl.bind_sequence(KeyEvent::ctrl('E'), EventHandler::Conditional(ceh.clone()));
diff --git a/examples/example.rs b/examples/example.rs
index fc53106..8ed975b 100644
--- a/examples/example.rs
+++ b/examples/example.rs
@@ -58,7 +58,7 @@ fn main() -> rustyline::Result<()> {
let h = MyHelper {
completer: FilenameCompleter::new(),
highlighter: MatchingBracketHighlighter::new(),
- hinter: HistoryHinter {},
+ hinter: HistoryHinter::new(),
colored_prompt: "".to_owned(),
validator: MatchingBracketValidator::new(),
};
diff --git a/src/hint.rs b/src/hint.rs
index ea28ca8..1b4f88a 100644
--- a/src/hint.rs
+++ b/src/hint.rs
@@ -50,8 +50,16 @@ impl<'r, H: ?Sized + Hinter> Hinter for &'r H {
/// Add suggestion based on previous history entries matching current user
/// input.
+#[derive(Default)]
pub struct HistoryHinter {}
+impl HistoryHinter {
+ /// Create a new `HistoryHinter`
+ pub fn new() -> HistoryHinter {
+ HistoryHinter::default()
+ }
+}
+
impl Hinter for HistoryHinter {
type Hint = String;