Comment

Struct Comment 

Source
pub struct Comment { /* private fields */ }
Expand description

A comment rule.

Comments do not generate tokens, unlike most rules. Instead, they are attached to the span of a token, and can be inspected through Span::comments().

Implementations§

Source§

impl Comment

Source

pub fn line(delim: impl Into<Yarn>) -> Self

Creates a new line comment. Line comments cannot nest, and run from starting delimiter (which is something like // or #) to the next '\n' character (not including it).

Source

pub fn block(open: impl Into<Yarn>, close: impl Into<Yarn>) -> Self

Creates a new nestable block comment with paired delimiters.

Source

pub fn nesting(bracket: Bracket) -> Self

Creates a new comment that can nest. For example, Rust block comments can nest: /* /* */ */

Source

pub fn non_nesting(bracket: Bracket) -> Self

Creates a new comment that can’t nest. For example, a line comment is a non-nesting comment where a newline ‘\n’ is the closing delimiter.

Trait Implementations§

Source§

impl Debug for Comment

Source§

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

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

impl From<&'static str> for Comment

Source§

fn from(value: &'static str) -> Self

Converts to this type from the input type.
Source§

impl<Y: Into<Yarn>, Z: Into<Yarn>> From<(Y, Z)> for Comment

Source§

fn from((y, z): (Y, Z)) -> Self

Converts to this type from the input type.
Source§

impl From<Comment> for Any

Source§

fn from(value: Comment) -> Self

Converts to this type from the input type.
Source§

impl From<YarnBox<'static, str>> for Comment

Source§

fn from(value: Yarn) -> Self

Converts to this type from the input type.
Source§

impl From<char> for Comment

Source§

fn from(value: char) -> Self

Converts to this type from the input type.
Source§

impl Rule for Comment

Source§

type Token<'lex> = Never

This rule’s corresponding token type. Read more
Source§

fn try_from_ref(value: &Any) -> Result<&Self, WrongKind>

Converts a reference to Any to a reference to this kind of rule.
Source§

impl TryFrom<Any> for Comment

Source§

type Error = WrongKind

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

fn try_from(value: Any) -> Result<Self, Self::Error>

Performs the conversion.

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> 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, 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.