pub struct Syntax { /* private fields */ }Expand description
The rules of one language, ready to scan text with.
Implementations§
Source§impl Syntax
impl Syntax
Sourcepub fn load(path: &Path) -> Result<Self, Error>
pub fn load(path: &Path) -> Result<Self, Error>
Reads a language file.
§Errors
Returns Error::Read if the file cannot be opened or holds a
duplicate key, and Error::Rule if a rule lacks the words it needs —
block_comment without both delimiters, or strings without one.
Sourcepub fn parse(text: &str) -> Result<Self, Error>
pub fn parse(text: &str) -> Result<Self, Error>
Parses a language definition from text, the same format load
reads from a file.
§Errors
Returns Error::Read if the text holds a duplicate key, and
Error::Rule if a rule lacks the words it needs.
Sourcepub fn covers(&self, extension: &str) -> bool
pub fn covers(&self, extension: &str) -> bool
Whether this language claims files ending in extension.
Sourcepub fn covers_language(&self, name: &str) -> bool
pub fn covers_language(&self, name: &str) -> bool
Whether this language answers to name, the way a markdown fence names
one. Both the names line and the extensions count, so ```rust
and ```rs find the same language.
Auto Trait Implementations§
impl Freeze for Syntax
impl RefUnwindSafe for Syntax
impl Send for Syntax
impl Sync for Syntax
impl Unpin for Syntax
impl UnsafeUnpin for Syntax
impl UnwindSafe for Syntax
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more