pub enum DispositionExplanation {
KeptByKind(CommentKind),
KeptByRegex {
index: usize,
pattern: String,
},
ProtectedPreamble,
KeptHtml,
KeptDirective {
kind: CommentKind,
name: Option<&'static str>,
},
KeptLicense {
marker: Option<&'static str>,
},
RemovedByKind(CommentKind),
RemovedByRegex {
index: usize,
pattern: String,
},
RemovedByPolicy(Policy),
RemovedByDefault(Policy),
KeptStructural {
language: Language,
},
}Expand description
Which rule decided one comment’s fate.
A Disposition says what happens and gives a short reason a machine
cannot take apart; an explanation names the branch, so a caller can quote
the pattern, kind or directive that actually applied. The variants are
listed in the order the rules are tested, and the first rule that applies is
the variant returned — keep overrides always win, and the policy default
is the last word.
Regex indices are zero-based positions in ScanOptions::keep_regex and
ScanOptions::remove_regex, and pattern is that entry verbatim.
One rule is not about the comment’s bytes at all and so is not a branch of
that table: Self::KeptStructural is decided by where the comment sits in
the file, is tested after every other rule, and is the answer only
explain_comment can give.
Variants§
KeptByKind(CommentKind)
The kind is listed in ScanOptions::keep_kinds.
KeptByRegex
A ScanOptions::keep_regex entry matched the whole comment token.
Fields
index: usizePosition of the entry in ScanOptions::keep_regex.
ProtectedPreamble
A shebang or encoding declaration the source needs to keep working;
only ScanOptions::force_protected gives it up.
KeptHtml
An HTML comment, which the DOM exposes to scripts.
KeptDirective
A directive addressed to a tool or to the compiler.
Fields
kind: CommentKindThe kind that was classified as a directive.
KeptLicense
A license or copyright notice under Policy::Legal.
RemovedByKind(CommentKind)
The kind is listed in ScanOptions::remove_kinds.
RemovedByRegex
A ScanOptions::remove_regex entry matched the whole comment token.
Fields
index: usizePosition of the entry in ScanOptions::remove_regex.
RemovedByPolicy(Policy)
The policy removes every comment it is offered.
RemovedByDefault(Policy)
Nothing protected an ordinary comment, so the policy default removed it.
KeptStructural
A comment every rule above would have removed, kept because a block scalar’s body ends at it and a comment the run keeps sits below it, deep enough that the body would take that comment back.
No option overrules this one: --policy all removes the comment below
it and the question with it, but a comment an override still keeps
leaves the value depending on this line.
Fields
language: LanguageThe language whose layout rule decided it, which is
Language::Yaml wherever this is returned today.
Implementations§
Source§impl DispositionExplanation
impl DispositionExplanation
Sourcepub const fn action(&self) -> Action
pub const fn action(&self) -> Action
The verdict alone. Equal to the Disposition the scanner records for
the same comment under the same options.
Trait Implementations§
Source§impl Clone for DispositionExplanation
impl Clone for DispositionExplanation
Source§fn clone(&self) -> DispositionExplanation
fn clone(&self) -> DispositionExplanation
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more