pub struct GrammarSet { /* private fields */ }Expand description
Owns the loaded grammar set used to resolve languages and build highlighters.
Implementations§
Source§impl GrammarSet
impl GrammarSet
Sourcepub fn default_set() -> Self
pub fn default_set() -> Self
Returns the bundled grammar set and panics only if embedded data is invalid.
Sourcepub fn load_grammar(&mut self, path: &Path) -> Result<(), GrammarLoadError>
pub fn load_grammar(&mut self, path: &Path) -> Result<(), GrammarLoadError>
Loads one grammar file and restores the previous set if reading or parsing fails.
Sourcepub fn detect_language<'a>(&'a self, extension: &str) -> Option<&'a str>
pub fn detect_language<'a>(&'a self, extension: &str) -> Option<&'a str>
Returns the display language name for an extension when a matching grammar exists.
Trait Implementations§
Source§impl Clone for GrammarSet
impl Clone for GrammarSet
Source§fn clone(&self) -> GrammarSet
fn clone(&self) -> GrammarSet
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !Freeze for GrammarSet
impl RefUnwindSafe for GrammarSet
impl Send for GrammarSet
impl Sync for GrammarSet
impl Unpin for GrammarSet
impl UnsafeUnpin for GrammarSet
impl UnwindSafe for GrammarSet
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