pub struct LabeledSpan { /* private fields */ }
Expand description
A labeled SourceSpan
.
Implementations§
Source§impl LabeledSpan
impl LabeledSpan
Sourcepub const fn new(
label: Option<String>,
offset: usize,
len: usize,
) -> LabeledSpan
pub const fn new( label: Option<String>, offset: usize, len: usize, ) -> LabeledSpan
Makes a new labeled span.
Sourcepub fn new_with_span(
label: Option<String>,
span: impl Into<SourceSpan>,
) -> LabeledSpan
pub fn new_with_span( label: Option<String>, span: impl Into<SourceSpan>, ) -> LabeledSpan
Makes a new labeled span using an existing span.
Sourcepub fn at(span: impl Into<SourceSpan>, label: impl Into<String>) -> LabeledSpan
pub fn at(span: impl Into<SourceSpan>, label: impl Into<String>) -> LabeledSpan
Makes a new label at specified span
§Examples
use miette::LabeledSpan;
let source = "Cpp is the best";
let label = LabeledSpan::at(0..3, "should be Rust");
assert_eq!(
label,
LabeledSpan::new(Some("should be Rust".to_string()), 0, 3)
)
Sourcepub fn at_offset(offset: usize, label: impl Into<String>) -> LabeledSpan
pub fn at_offset(offset: usize, label: impl Into<String>) -> LabeledSpan
Makes a new label that points at a specific offset.
§Examples
use miette::LabeledSpan;
let source = "(2 + 2";
let label = LabeledSpan::at_offset(4, "expected a closing parenthesis");
assert_eq!(
label,
LabeledSpan::new(Some("expected a closing parenthesis".to_string()), 4, 0)
)
Sourcepub fn underline(span: impl Into<SourceSpan>) -> LabeledSpan
pub fn underline(span: impl Into<SourceSpan>) -> LabeledSpan
Makes a new label without text, that underlines a specific span.
§Examples
use miette::LabeledSpan;
let source = "You have an eror here";
let label = LabeledSpan::underline(12..16);
assert_eq!(label, LabeledSpan::new(None, 12, 4))
Sourcepub const fn inner(&self) -> &SourceSpan
pub const fn inner(&self) -> &SourceSpan
Returns a reference to the inner SourceSpan
.
Trait Implementations§
Source§impl Clone for LabeledSpan
impl Clone for LabeledSpan
Source§fn clone(&self) -> LabeledSpan
fn clone(&self) -> LabeledSpan
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for LabeledSpan
impl Debug for LabeledSpan
Source§impl From<Label> for LabeledSpan
impl From<Label> for LabeledSpan
Source§fn from(label: Label) -> LabeledSpan
fn from(label: Label) -> LabeledSpan
Converts to this type from the input type.
Source§impl PartialEq for LabeledSpan
impl PartialEq for LabeledSpan
impl Eq for LabeledSpan
impl StructuralPartialEq for LabeledSpan
Auto Trait Implementations§
impl Freeze for LabeledSpan
impl RefUnwindSafe for LabeledSpan
impl Send for LabeledSpan
impl Sync for LabeledSpan
impl Unpin for LabeledSpan
impl UnwindSafe for LabeledSpan
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<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more