Skip to main content

SkipPolicy

Enum SkipPolicy 

Source
pub enum SkipPolicy {
    None,
    Whitespace,
    Newlines,
}
Expand description

How chars(P, skip:) trims between matches (§7.5).

Read the two non-None variants as an inclusion, because the names do not say so. Whitespace is horizontal whitespace; Newlines is horizontal whitespace and line endings. So Newlines skips strictly more than Whitespacewhitespace is the narrower policy despite being the broader English word, and skip: newlines means “newlines as well”, not “newlines only”.

That inversion is not academic: chars(one_of("^v<>"), skip: whitespace) — §7.5’s own example — looks like it should absorb an input file’s trailing \n. It does not, and it does not have to: the terminator is inside the root region — the root region is the whole buffer, and nothing is trimmed off it — and it is forgiven because it is whitespace the character parser declined (walk_characters asks the child first and accepts a whitespace-only leftover through ByteRegion::is_all_whitespace, the bound half of ADR-078’s rule). No skip policy has to account for it. The sets are the ones §7.5’s example needs, and swapping them would silently change what every existing skip: newlines program accepts. walk_characters / skip_chars in praxis-runtime is the implementation, and SkipPolicy::skips below is the single description both the runtime comment and the skip: diagnostic quote.

Variants§

§

None

No trimming between matches: every byte of the region is the child’s.

§

Whitespace

Skip horizontal whitespace — spaces and tabs — between matches. Not line endings: see the type’s own documentation.

§

Newlines

Skip horizontal whitespace and line endings between matches. The broader of the two policies.

Implementations§

Source§

impl SkipPolicy

Source

pub const ALL: &'static [SkipPolicy]

Every policy, in §7.5’s order. The list is closed: a test sweeps it.

Source

pub fn from_keyword(name: &str) -> Option<Self>

Parse a skip: keyword value, or None if unknown.

Source

pub fn skips(self) -> &'static str

What this policy skips, in the words the skip: diagnostic uses.

One description, quoted by the diagnostic and by the runtime, so a reader who reaches either one is told that newlines is the broader policy rather than left to infer it from the names.

Trait Implementations§

Source§

impl Clone for SkipPolicy

Source§

fn clone(&self) -> SkipPolicy

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 Copy for SkipPolicy

Source§

impl Debug for SkipPolicy

Source§

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

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

impl Eq for SkipPolicy

Source§

impl PartialEq for SkipPolicy

Source§

fn eq(&self, other: &SkipPolicy) -> 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 SkipPolicy

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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.