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§
type Item: OptionEntry
Required Methods§
Provided Methods§
fn lookup(&self, name: &str) -> Vec<Loc<&Self::Item>>
Sourcefn find_all_strings(
&self,
diag: &mut Diagnostics,
name: &str,
) -> Result<Vec<Loc<String>>, ()>
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.
fn find_all_u32( &self, diag: &mut Diagnostics, name: &str, ) -> Result<Vec<Loc<RpNumber>>, ()>
Sourcefn find_all_identifiers(
&self,
diag: &mut Diagnostics,
name: &str,
) -> Result<Vec<Loc<String>>, ()>
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.
Sourcefn find_one_identifier(
&self,
diag: &mut Diagnostics,
name: &str,
) -> Result<Option<Loc<String>>, ()>
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.