Trait Glossary

Source
pub trait Glossary: Debug {
    // Required method
    fn look_up(&self, name: &str) -> Option<Rc<Alias>>;

    // Provided method
    fn is_empty(&self) -> bool { ... }
}
Expand description

Interface used by the parser to look up aliases

This trait is an abstract interface that represents an immutable collection of aliases. The parser uses this trait to look up aliases when it encounters a command word in a simple command.

Required Methods§

Source

fn look_up(&self, name: &str) -> Option<Rc<Alias>>

Looks up an alias by name.

If an alias with the given name is found, it is returned. Otherwise, the return value is None.

Provided Methods§

Source

fn is_empty(&self) -> bool

Returns whether the glossary is empty.

If the glossary is empty, the parser can skip alias expansion. This method is used as a hint to optimize alias expansion.

If the glossary has any aliases, it must return false.

The default implementation returns false.

Implementations on Foreign Types§

Source§

impl<T: Glossary> Glossary for &T

Source§

fn look_up(&self, name: &str) -> Option<Rc<Alias>>

Source§

fn is_empty(&self) -> bool

Source§

impl<T: Glossary> Glossary for &mut T

Source§

fn look_up(&self, name: &str) -> Option<Rc<Alias>>

Source§

fn is_empty(&self) -> bool

Source§

impl<T: Glossary> Glossary for RefCell<T>

Allows a glossary to be wrapped in a RefCell.

This implementation’s methods immutably borrow the inner glossary. If the inner glossary is mutably borrowed at the same time, it panics.

Source§

fn look_up(&self, name: &str) -> Option<Rc<Alias>>

Source§

fn is_empty(&self) -> bool

Implementors§