Struct miden_core::debuginfo::Span
source · pub struct Span<T> { /* private fields */ }
Expand description
This type is used to wrap any T
with a SourceSpan, and is typically used when it is not
convenient to add a SourceSpan to the type - most commonly because we don’t control the type.
Implementations§
source§impl<T> Span<T>
impl<T> Span<T>
sourcepub fn new(span: impl Into<SourceSpan>, spanned: T) -> Self
pub fn new(span: impl Into<SourceSpan>, spanned: T) -> Self
Creates a span for spanned
with span
.
sourcepub fn at(source_id: SourceId, offset: usize, spanned: T) -> Self
pub fn at(source_id: SourceId, offset: usize, spanned: T) -> Self
Creates a span for spanned
representing a single location, offset
.
sourcepub fn unknown(spanned: T) -> Self
pub fn unknown(spanned: T) -> Self
Creates a Span from a value with an unknown/default location.
sourcepub const fn span(&self) -> SourceSpan
pub const fn span(&self) -> SourceSpan
Gets the associated SourceSpan for this spanned item.
sourcepub fn map<U, F>(self, f: F) -> Span<U>where
F: FnMut(T) -> U,
pub fn map<U, F>(self, f: F) -> Span<U>where
F: FnMut(T) -> U,
Applies a transformation to the spanned value while retaining the same SourceSpan.
sourcepub fn as_deref<U>(&self) -> Span<&U>
pub fn as_deref<U>(&self) -> Span<&U>
Like Option<T>::as_deref
, this constructs a Span<U>
wrapping the result of
dereferencing the inner value of type T
as a value of type U
.
sourcepub fn shift(&mut self, count: ByteOffset)
pub fn shift(&mut self, count: ByteOffset)
Shifts the span right by count
units
sourcepub fn extend(&mut self, count: ByteOffset)
pub fn extend(&mut self, count: ByteOffset)
Extends the end of the span by count
units.
sourcepub fn into_parts(self) -> (SourceSpan, T)
pub fn into_parts(self) -> (SourceSpan, T)
Consumes this span, returning the component parts, i.e. the SourceSpan and value of type
T
.
sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Unwraps the spanned value of type T
.
source§impl<T: Serializable> Span<T>
impl<T: Serializable> Span<T>
pub fn write_into_with_options<W: ByteWriter>( &self, target: &mut W, debug: bool, )
source§impl<T: Deserializable> Span<T>
impl<T: Deserializable> Span<T>
pub fn read_from_with_options<R: ByteReader>( source: &mut R, debug: bool, ) -> Result<Self, DeserializationError>
Trait Implementations§
source§impl<T: Deserializable> Deserializable for Span<T>
impl<T: Deserializable> Deserializable for Span<T>
source§fn read_from<R: ByteReader>(
source: &mut R,
) -> Result<Self, DeserializationError>
fn read_from<R: ByteReader>( source: &mut R, ) -> Result<Self, DeserializationError>
source
, attempts to deserialize these bytes
into Self
, and returns the result. Read moresource§fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>
fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>
source§impl<T: Ord> Ord for Span<T>
impl<T: Ord> Ord for Span<T>
source§impl<T: PartialOrd> PartialOrd for Span<T>
impl<T: PartialOrd> PartialOrd for Span<T>
source§impl<T: PrettyPrint> PrettyPrint for Span<T>
impl<T: PrettyPrint> PrettyPrint for Span<T>
source§fn to_pretty_string(&self) -> String
fn to_pretty_string(&self) -> String
source§fn pretty_print(&self, f: &mut Formatter<'_>) -> Result<(), Error>
fn pretty_print(&self, f: &mut Formatter<'_>) -> Result<(), Error>
source§impl<T: Serializable> Serializable for Span<T>
impl<T: Serializable> Serializable for Span<T>
source§fn write_into<W: ByteWriter>(&self, target: &mut W)
fn write_into<W: ByteWriter>(&self, target: &mut W)
self
into bytes and writes these bytes into the target
.source§fn get_size_hint(&self) -> usize
fn get_size_hint(&self) -> usize
impl<T: Copy> Copy for Span<T>
impl<T: Eq> Eq for Span<T>
Auto Trait Implementations§
impl<T> Freeze for Span<T>where
T: Freeze,
impl<T> RefUnwindSafe for Span<T>where
T: RefUnwindSafe,
impl<T> Send for Span<T>where
T: Send,
impl<T> Sync for Span<T>where
T: Sync,
impl<T> Unpin for Span<T>where
T: Unpin,
impl<T> UnwindSafe for Span<T>where
T: UnwindSafe,
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)