pub struct LabeledSpan { /* private fields */ }
Expand description
A labeled SourceSpan
.
Implementations§
Source§impl LabeledSpan
impl LabeledSpan
Sourcepub const fn new(label: Option<String>, offset: ByteOffset, len: usize) -> Self
pub const fn new(label: Option<String>, offset: ByteOffset, len: usize) -> Self
Makes a new labeled span.
Sourcepub fn new_with_span(label: Option<String>, span: impl Into<SourceSpan>) -> Self
pub fn new_with_span(label: Option<String>, span: impl Into<SourceSpan>) -> Self
Makes a new labeled span using an existing span.
Sourcepub fn new_primary_with_span(
label: Option<String>,
span: impl Into<SourceSpan>,
) -> Self
pub fn new_primary_with_span( label: Option<String>, span: impl Into<SourceSpan>, ) -> Self
Makes a new labeled primary span using an existing span.
Sourcepub fn at(span: impl Into<SourceSpan>, label: impl Into<String>) -> Self
pub fn at(span: impl Into<SourceSpan>, label: impl Into<String>) -> Self
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: ByteOffset, label: impl Into<String>) -> Self
pub fn at_offset(offset: ByteOffset, label: impl Into<String>) -> Self
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>) -> Self
pub fn underline(span: impl Into<SourceSpan>) -> Self
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 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