pub struct RuleSet { /* private fields */ }Expand description
An ordered, name-unique collection of LintRules.
Implementations§
Source§impl RuleSet
impl RuleSet
Sourcepub fn stdlib_defaults() -> Self
pub fn stdlib_defaults() -> Self
The stdlib’s curated default-on rules. Equivalent to
crate::stdlib::defaults.
Sourcepub fn stdlib_all() -> Self
pub fn stdlib_all() -> Self
Every stdlib rule, including the default-off ones.
Equivalent to crate::stdlib::all.
Sourcepub fn add(
&mut self,
rule: Box<dyn LintRule>,
) -> Result<&mut Self, DuplicateRuleName>
pub fn add( &mut self, rule: Box<dyn LintRule>, ) -> Result<&mut Self, DuplicateRuleName>
Insert a rule. Names must be unique within the set.
§Errors
Returns DuplicateRuleName if a rule with the same
name() is already present.
Sourcepub fn remove(&mut self, name: &str) -> bool
pub fn remove(&mut self, name: &str) -> bool
Remove the rule with the given name. Returns true if a
rule was removed, false if no rule had that name.
pub fn contains(&self, name: &str) -> bool
pub fn iter(&self) -> impl Iterator<Item = &dyn LintRule>
Sourcepub fn names(&self) -> impl Iterator<Item = &str>
pub fn names(&self) -> impl Iterator<Item = &str>
Iterate over the names of every rule in the set.
Sourcepub fn check(&self, doc: &Document) -> Vec<Diagnostic>
pub fn check(&self, doc: &Document) -> Vec<Diagnostic>
Run every rule in the set over doc.
Sourcepub fn check_with(&self, doc: &Document, opts: LintOptions) -> Vec<Diagnostic>
pub fn check_with(&self, doc: &Document, opts: LintOptions) -> Vec<Diagnostic>
Run every rule in the set over doc under opts.
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Trait Implementations§
Source§impl IntoIterator for RuleSet
Consumes the set and yields its rules in insertion order.
impl IntoIterator for RuleSet
Consumes the set and yields its rules in insertion order.
Required by the CLI’s --rules selector, which partitions the
available pool of rules into the user-requested subset without
cloning trait objects (LintRule is not Clone).