Skip to main content

IrEvent

Enum IrEvent 

Source
pub enum IrEvent {
    Text {
        start: usize,
        end: usize,
    },
    Construct {
        start: usize,
        end: usize,
        kind: ConstructKind,
    },
    DelimRun {
        ch: u8,
        start: usize,
        end: usize,
        can_open: bool,
        can_close: bool,
        matches: Vec<DelimMatch>,
    },
    OpenBracket {
        start: usize,
        end: usize,
        is_image: bool,
        active: bool,
        resolution: Option<BracketResolution>,
    },
    CloseBracket {
        pos: usize,
        matched: bool,
    },
    SoftBreak {
        start: usize,
        end: usize,
    },
    HardBreak {
        start: usize,
        end: usize,
    },
}
Expand description

One event in the inline IR.

Events partition the source byte range covered by the IR exactly: their range() values are contiguous and non-overlapping, so concatenating them reproduces the original input. This is the losslessness invariant the emission pass relies on.

Variants§

§

Text

Plain text byte span. Emitted as a single TEXT token, possibly merged with adjacent literal-disposition delim/bracket bytes.

Fields

§start: usize
§end: usize
§

Construct

An opaque higher-precedence construct (escape, code span, autolink, raw HTML). The emission pass re-parses these from the source byte range using the existing per-construct emitters; we don’t store a pre-built GreenNode because rowan::GreenNodeBuilder doesn’t support inserting subtrees directly. The byte range is what makes emission well-defined — the construct kind is recovered by the emitter dispatching on the leading byte.

Fields

§start: usize
§end: usize
§

DelimRun

A * or _ delimiter run. The matches vec is filled in by process_emphasis; before that pass it is empty.

Fields

§ch: u8
§start: usize
§end: usize
§can_open: bool
§can_close: bool
§matches: Vec<DelimMatch>

Matched fragments produced by process_emphasis. Each entry is one (byte_offset_within_run, len, partner_event_idx, partner_byte_offset, kind, is_opener) tuple. Empty until the pass runs; possibly multiple entries when a single run matches at multiple positions (e.g. a 4-run that closes 2+2 pairs).

§

OpenBracket

[ or ![ bracket marker. Resolved by process_brackets.

Fields

§start: usize
§end: usize

start + 1 for [, start + 2 for ![.

§is_image: bool
§active: bool

True until a later resolution rule deactivates this opener.

§resolution: Option<BracketResolution>

Filled in when the matching CloseBracket resolves the pair to a link / image.

§

CloseBracket

] bracket marker. Resolved by process_brackets.

Fields

§pos: usize
§matched: bool

True if this ] was paired with an opener and the pair was turned into a link / image.

§

SoftBreak

A soft line break (a \n or \r\n ending a paragraph-internal line). Includes the line-ending bytes verbatim.

Fields

§start: usize
§end: usize
§

HardBreak

A hard line break ( \n / \\\n / \n etc.). Includes any trailing-space bytes plus the line ending.

Fields

§start: usize
§end: usize

Implementations§

Source§

impl IrEvent

Source

pub fn range(&self) -> (usize, usize)

The source byte range this event covers.

Trait Implementations§

Source§

impl Clone for IrEvent

Source§

fn clone(&self) -> IrEvent

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for IrEvent

Source§

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

Formats the value using the given formatter. Read more

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