pub trait Completer {
    type Candidate: Candidate;

    // Required method
    fn complete(
        &self,
        line: &str,
        pos: usize
    ) -> Result<(usize, Vec<Self::Candidate>)>;

    // Provided method
    fn update(&self, line: &mut LineBuffer, start: usize, elected: &str) { ... }
}
Expand description

To be called for tab-completion.

Required Associated Types§

Required Methods§

source

fn complete( &self, line: &str, pos: usize ) -> Result<(usize, Vec<Self::Candidate>)>

Takes the currently edited line with the cursor position and returns the start position and the completion candidates for the partial word to be completed.

(“ls /usr/loc”, 11) => Ok((3, vec![“/usr/local/”]))

Provided Methods§

source

fn update(&self, line: &mut LineBuffer, start: usize, elected: &str)

Updates the edited line with the elected candidate.

Implementations on Foreign Types§

source§

impl Completer for ()

§

type Candidate = String

source§

fn complete(&self, _line: &str, _pos: usize) -> Result<(usize, Vec<String>)>

source§

fn update(&self, _line: &mut LineBuffer, _start: usize, _elected: &str)

source§

impl<'c, C: ?Sized + Completer> Completer for &'c C

§

type Candidate = <C as Completer>::Candidate

source§

fn complete( &self, line: &str, pos: usize ) -> Result<(usize, Vec<Self::Candidate>)>

source§

fn update(&self, line: &mut LineBuffer, start: usize, elected: &str)

source§

impl<C: ?Sized + Completer> Completer for Box<C>

§

type Candidate = <C as Completer>::Candidate

source§

fn complete( &self, line: &str, pos: usize ) -> Result<(usize, Vec<Self::Candidate>)>

source§

fn update(&self, line: &mut LineBuffer, start: usize, elected: &str)

source§

impl<C: ?Sized + Completer> Completer for Rc<C>

§

type Candidate = <C as Completer>::Candidate

source§

fn complete( &self, line: &str, pos: usize ) -> Result<(usize, Vec<Self::Candidate>)>

source§

fn update(&self, line: &mut LineBuffer, start: usize, elected: &str)

source§

impl<C: ?Sized + Completer> Completer for Arc<C>

§

type Candidate = <C as Completer>::Candidate

source§

fn complete( &self, line: &str, pos: usize ) -> Result<(usize, Vec<Self::Candidate>)>

source§

fn update(&self, line: &mut LineBuffer, start: usize, elected: &str)

Implementors§