pub struct Span {
pub start: Position,
pub end: Position,
}Expand description
A span representing a range in the source document.
Spans are inclusive of the start position and exclusive of the end position. This matches CommonMark and most parser conventions.
§Example
For the text “bold”:
start: Position at the first ‘*’end: Position after the last ‘*’ (one past the last character)
§Multi-line Spans
For multi-line content like code blocks, for example a fenced Rust code block, the inner code might look like:
fn main() {
}start.line: Line of opening backticksend.line: Line after closing backticks- Columns are byte offsets within their respective lines
Fields§
§start: PositionStart position (inclusive)
end: PositionEnd position (exclusive)
Implementations§
Source§impl Span
impl Span
Sourcepub fn new(start: Position, end: Position) -> Self
pub fn new(start: Position, end: Position) -> Self
Create a new span from inclusive start and exclusive end positions.
Sourcepub fn start_line_offset(&self) -> usize
pub fn start_line_offset(&self) -> usize
Return the absolute byte offset of the start of the span’s first line.
This is a convenience wrapper around Position::line_start_offset for
the span’s start position.
Sourcepub fn end_line_offset(&self) -> usize
pub fn end_line_offset(&self) -> usize
Return the absolute byte offset of the start of the span’s end line. Useful when expanding a span to include the whole end line.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Span
impl<'de> Deserialize<'de> for Span
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Copy for Span
impl Eq for Span
impl StructuralPartialEq for Span
Auto Trait Implementations§
impl Freeze for Span
impl RefUnwindSafe for Span
impl Send for Span
impl Sync for Span
impl Unpin for Span
impl UnsafeUnpin for Span
impl UnwindSafe for Span
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.