Skip to main content

DispositionExplanation

Enum DispositionExplanation 

Source
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: usize

Position of the entry in ScanOptions::keep_regex.

§pattern: String

That entry, verbatim.

§

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: CommentKind

The kind that was classified as a directive.

§name: Option<&'static str>

The directive’s name, when the catalogue could name it.

§

KeptLicense

A license or copyright notice under Policy::Legal.

Fields

§marker: Option<&'static str>

The marker that identified it, such as spdx-license-identifier.

§

RemovedByKind(CommentKind)

The kind is listed in ScanOptions::remove_kinds.

§

RemovedByRegex

A ScanOptions::remove_regex entry matched the whole comment token.

Fields

§index: usize

Position of the entry in ScanOptions::remove_regex.

§pattern: String

That entry, verbatim.

§

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: Language

The language whose layout rule decided it, which is Language::Yaml wherever this is returned today.

Implementations§

Source§

impl DispositionExplanation

Source

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

Source§

fn clone(&self) -> DispositionExplanation

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DispositionExplanation

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for DispositionExplanation

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for DispositionExplanation

Source§

impl PartialEq for DispositionExplanation

Source§

fn eq(&self, other: &DispositionExplanation) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for DispositionExplanation

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.