Struct doc_chunks::span::Span
source · [−]pub struct Span {
pub start: LineColumn,
pub end: LineColumn,
}Expand description
Relative span in relation to the beginning of a doc comment.
Line values are 1-indexed relative, lines are inclusive. Column values in UTF-8 characters in a line, 0-indexed and inclusive.
Fields
start: LineColumnStart of the span, inclusive, see
LineColumn.
end: LineColumnEnd of the span, inclusive, see LineColumn.
Implementations
sourceimpl Span
impl Span
sourcepub fn relative_to<X: Into<Span>>(&self, scope: X) -> Result<Range>
pub fn relative_to<X: Into<Span>>(&self, scope: X) -> Result<Range>
Converts a span to a range, where self is converted to a range
relative to the passed span scope. Only works for literals spanning a
single line and the scope full contains self, otherwise an an Err(..)`
is returned.
sourcepub fn covers_line(&self, line: usize) -> bool
pub fn covers_line(&self, line: usize) -> bool
Check if self span covers provided line number, which is 1-indexed.
sourcepub fn one_line_len(&self) -> Option<usize>
pub fn one_line_len(&self) -> Option<usize>
If this one resembles a single line, returns the a Some(len) value.
For multilines this cannot account for the length.
sourcepub fn is_multiline(&self) -> bool
pub fn is_multiline(&self) -> bool
Check if self covers multiple lines
sourcepub fn to_content_range(&self, chunk: &CheckableChunk) -> Result<Range>
pub fn to_content_range(&self, chunk: &CheckableChunk) -> Result<Range>
Convert a given span self into a Range
The Chunk has a associated Span (or a set of Range -> Span
mappings) which are used to map.
Trait Implementations
sourceimpl From<&'_ TrimmedLiteral> for Span
impl From<&'_ TrimmedLiteral> for Span
sourcefn from(literal: &TrimmedLiteral) -> Self
fn from(literal: &TrimmedLiteral) -> Self
Converts to this type from the input type.
impl Copy for Span
impl Eq for Span
impl StructuralEq for Span
impl StructuralPartialEq for Span
Auto Trait Implementations
impl RefUnwindSafe for Span
impl Send for Span
impl Sync for Span
impl Unpin for Span
impl UnwindSafe for Span
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key and return true if they are equal.
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more