From b6473661960224561bc47a40aa328d624b57d560 Mon Sep 17 00:00:00 2001 From: gwenn Date: Mon, 7 Oct 2024 15:04:04 +0200 Subject: [PATCH] Remove impl for & Trying to fix #425 --- src/completion.rs | 16 ------------- src/highlight.rs | 30 ------------------------ src/hint.rs | 8 ------- src/lib.rs | 2 -- src/tty/mod.rs | 60 ----------------------------------------------- src/validate.rs | 10 -------- 6 files changed, 126 deletions(-) diff --git a/src/completion.rs b/src/completion.rs index b39e927d5..e466d977b 100644 --- a/src/completion.rs +++ b/src/completion.rs @@ -82,22 +82,6 @@ impl Completer for () { } } -impl<'c, C: ?Sized + Completer> Completer for &'c C { - type Candidate = C::Candidate; - - fn complete( - &self, - line: &str, - pos: usize, - ctx: &Context<'_>, - ) -> Result<(usize, Vec)> { - (**self).complete(line, pos, ctx) - } - - fn update(&self, line: &mut LineBuffer, start: usize, elected: &str, cl: &mut Changeset) { - (**self).update(line, start, elected, cl); - } -} macro_rules! box_completer { ($($id: ident)*) => { $( diff --git a/src/highlight.rs b/src/highlight.rs index ffee71e76..6cc718a07 100644 --- a/src/highlight.rs +++ b/src/highlight.rs @@ -70,36 +70,6 @@ pub trait Highlighter { impl Highlighter for () {} -impl<'r, H: ?Sized + Highlighter> Highlighter for &'r H { - fn highlight<'l>(&self, line: &'l str, pos: usize) -> Cow<'l, str> { - (**self).highlight(line, pos) - } - - fn highlight_prompt<'b, 's: 'b, 'p: 'b>( - &'s self, - prompt: &'p str, - default: bool, - ) -> Cow<'b, str> { - (**self).highlight_prompt(prompt, default) - } - - fn highlight_hint<'h>(&self, hint: &'h str) -> Cow<'h, str> { - (**self).highlight_hint(hint) - } - - fn highlight_candidate<'c>( - &self, - candidate: &'c str, - completion: CompletionType, - ) -> Cow<'c, str> { - (**self).highlight_candidate(candidate, completion) - } - - fn highlight_char(&self, line: &str, pos: usize, kind: CmdKind) -> bool { - (**self).highlight_char(line, pos, kind) - } -} - // TODO versus https://python-prompt-toolkit.readthedocs.io/en/master/pages/reference.html?highlight=HighlightMatchingBracketProcessor#prompt_toolkit.layout.processors.HighlightMatchingBracketProcessor /// Highlight matching bracket when typed or cursor moved on. diff --git a/src/hint.rs b/src/hint.rs index efff9357c..5543f2e8c 100644 --- a/src/hint.rs +++ b/src/hint.rs @@ -40,14 +40,6 @@ impl Hinter for () { type Hint = String; } -impl<'r, H: ?Sized + Hinter> Hinter for &'r H { - type Hint = H::Hint; - - fn hint(&self, line: &str, pos: usize, ctx: &Context<'_>) -> Option { - (**self).hint(line, pos, ctx) - } -} - /// Add suggestion based on previous history entries matching current user /// input. #[derive(Default)] diff --git a/src/lib.rs b/src/lib.rs index 41675730a..c48757e42 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -550,8 +550,6 @@ where impl Helper for () {} -impl<'h, H: ?Sized + Helper> Helper for &'h H {} - /// Completion/suggestion context pub struct Context<'h> { history: &'h dyn History, diff --git a/src/tty/mod.rs b/src/tty/mod.rs index d5a0c7cf9..22dcb8a2b 100644 --- a/src/tty/mod.rs +++ b/src/tty/mod.rs @@ -118,66 +118,6 @@ pub trait Renderer { fn move_cursor_at_leftmost(&mut self, rdr: &mut Self::Reader) -> Result<()>; } -impl<'a, R: Renderer + ?Sized> Renderer for &'a mut R { - type Reader = R::Reader; - - fn move_cursor(&mut self, old: Position, new: Position) -> Result<()> { - (**self).move_cursor(old, new) - } - - fn refresh_line( - &mut self, - prompt: &str, - line: &LineBuffer, - hint: Option<&str>, - old_layout: &Layout, - new_layout: &Layout, - highlighter: Option<&dyn Highlighter>, - ) -> Result<()> { - (**self).refresh_line(prompt, line, hint, old_layout, new_layout, highlighter) - } - - fn calculate_position(&self, s: &str, orig: Position) -> Position { - (**self).calculate_position(s, orig) - } - - fn write_and_flush(&mut self, buf: &str) -> Result<()> { - (**self).write_and_flush(buf) - } - - fn beep(&mut self) -> Result<()> { - (**self).beep() - } - - fn clear_screen(&mut self) -> Result<()> { - (**self).clear_screen() - } - - fn clear_rows(&mut self, layout: &Layout) -> Result<()> { - (**self).clear_rows(layout) - } - - fn update_size(&mut self) { - (**self).update_size(); - } - - fn get_columns(&self) -> usize { - (**self).get_columns() - } - - fn get_rows(&self) -> usize { - (**self).get_rows() - } - - fn colors_enabled(&self) -> bool { - (**self).colors_enabled() - } - - fn move_cursor_at_leftmost(&mut self, rdr: &mut R::Reader) -> Result<()> { - (**self).move_cursor_at_leftmost(rdr) - } -} - // ignore ANSI escape sequence fn width(s: &str, esc_seq: &mut u8) -> usize { if *esc_seq == 1 { diff --git a/src/validate.rs b/src/validate.rs index 12b7f3314..f1475cd47 100644 --- a/src/validate.rs +++ b/src/validate.rs @@ -86,16 +86,6 @@ pub trait Validator { impl Validator for () {} -impl<'v, V: ?Sized + Validator> Validator for &'v V { - fn validate(&self, ctx: &mut ValidationContext) -> Result { - (**self).validate(ctx) - } - - fn validate_while_typing(&self) -> bool { - (**self).validate_while_typing() - } -} - /// Simple matching bracket validator. #[derive(Default)] pub struct MatchingBracketValidator {