Skip to content

Commit

Permalink
Remove impl for &
Browse files Browse the repository at this point in the history
Trying to fix #425
  • Loading branch information
gwenn committed Oct 7, 2024
1 parent 4363c5b commit b647366
Show file tree
Hide file tree
Showing 6 changed files with 0 additions and 126 deletions.
16 changes: 0 additions & 16 deletions src/completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::Candidate>)> {
(**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)*) => {
$(
Expand Down
30 changes: 0 additions & 30 deletions src/highlight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 0 additions & 8 deletions src/hint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
(**self).hint(line, pos, ctx)
}
}

/// Add suggestion based on previous history entries matching current user
/// input.
#[derive(Default)]
Expand Down
2 changes: 0 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
60 changes: 0 additions & 60 deletions src/tty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 0 additions & 10 deletions src/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ValidationResult> {
(**self).validate(ctx)
}

fn validate_while_typing(&self) -> bool {
(**self).validate_while_typing()
}
}

/// Simple matching bracket validator.
#[derive(Default)]
pub struct MatchingBracketValidator {
Expand Down

0 comments on commit b647366

Please sign in to comment.