Trait Options

Source
pub trait Options {
    type Item: OptionEntry;

    // Required method
    fn items(&self) -> &Vec<Loc<Self::Item>>;

    // Provided methods
    fn lookup(&self, name: &str) -> Vec<Loc<&Self::Item>> { ... }
    fn find_all_strings(
        &self,
        diag: &mut Diagnostics,
        name: &str,
    ) -> Result<Vec<Loc<String>>, ()> { ... }
    fn find_all_u32(
        &self,
        diag: &mut Diagnostics,
        name: &str,
    ) -> Result<Vec<Loc<RpNumber>>, ()> { ... }
    fn find_all_identifiers(
        &self,
        diag: &mut Diagnostics,
        name: &str,
    ) -> Result<Vec<Loc<String>>, ()> { ... }
    fn find_one_identifier(
        &self,
        diag: &mut Diagnostics,
        name: &str,
    ) -> Result<Option<Loc<String>>, ()> { ... }
    fn find_one_string(
        &self,
        diag: &mut Diagnostics,
        name: &str,
    ) -> Result<Option<Loc<String>>, ()> { ... }
    fn find_one_u32(
        &self,
        diag: &mut Diagnostics,
        name: &str,
    ) -> Result<Option<Loc<RpNumber>>, ()> { ... }
}
Expand description

Helper for looking up and dealing with options.

Required Associated Types§

Required Methods§

Source

fn items(&self) -> &Vec<Loc<Self::Item>>

Provided Methods§

Source

fn lookup(&self, name: &str) -> Vec<Loc<&Self::Item>>

Source

fn find_all_strings( &self, diag: &mut Diagnostics, name: &str, ) -> Result<Vec<Loc<String>>, ()>

Find all strings matching the given name.

This enforces that all found values are strings, otherwise the lookup will cause an error.

Source

fn find_all_u32( &self, diag: &mut Diagnostics, name: &str, ) -> Result<Vec<Loc<RpNumber>>, ()>

Source

fn find_all_identifiers( &self, diag: &mut Diagnostics, name: &str, ) -> Result<Vec<Loc<String>>, ()>

Find all identifiers matching the given name.

This enforces that all found values are identifiers, otherwise the lookup will cause an error.

Source

fn find_one_identifier( &self, diag: &mut Diagnostics, name: &str, ) -> Result<Option<Loc<String>>, ()>

Optionally find exactly one identifier matching the given name.

This enforces that all found values are identifiers, otherwise the lookup will cause an error.

Source

fn find_one_string( &self, diag: &mut Diagnostics, name: &str, ) -> Result<Option<Loc<String>>, ()>

Source

fn find_one_u32( &self, diag: &mut Diagnostics, name: &str, ) -> Result<Option<Loc<RpNumber>>, ()>

Implementations on Foreign Types§

Source§

impl<T> Options for Vec<Loc<T>>
where T: OptionEntry,

Source§

type Item = T

Source§

fn items(&self) -> &Vec<Loc<Self::Item>>

Implementors§