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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)