pub struct Loc<T> {
pub inner: T,
pub span: Span,
pub file_id: usize,
}Fields§
§inner: T§span: Span§file_id: usizeImplementations§
Source§impl<T> Loc<T>
impl<T> Loc<T>
pub fn new(inner: T, span: Span, file_id: usize) -> Self
pub fn nowhere(inner: T) -> Self
pub fn strip(self) -> T
pub fn strip_ref(&self) -> &T
pub fn separate(self) -> (Self, Span)
pub fn separate_loc(self) -> (Self, Loc<()>)
pub fn split(self) -> (T, Span)
pub fn split_ref(&self) -> (&T, Span)
pub fn split_loc(self) -> (T, Loc<()>)
pub fn split_loc_ref(&self) -> (&T, Loc<()>)
pub fn is_same_loc<R>(&self, other: &Loc<R>) -> bool
pub fn map<Y>(self, op: impl FnMut(T) -> Y) -> Loc<Y>
pub fn try_map<Y, E>( self, op: impl FnMut(T) -> Result<Y, E>, ) -> Result<Loc<Y>, E>
pub fn map_ref<Y>(&self, op: impl FnMut(&T) -> Y) -> Loc<Y>
pub fn try_map_ref<Y, E>( &self, op: impl FnMut(&T) -> Result<Y, E>, ) -> Result<Loc<Y>, E>
pub fn loc(&self) -> Loc<()>
pub fn contains_start<R>(&self, other: &Loc<R>) -> bool
pub fn start_span(&self) -> Loc<()>
pub fn end_span(&self) -> Loc<()>
Sourcepub fn shrink_left(&self, s: &str) -> Loc<()>
pub fn shrink_left(&self, s: &str) -> Loc<()>
Shrinks a Loc on the left size by the width of the specified string. For example (( abc )) ^^^^^^^^^ .shrink_left(“((”) results in For example (( abc )) ^^^^^^^
Note that this is only valid if the loc actually points to the specified string, otherwise the behaviour is undefined
If the span is empty, does nothing
Sourcepub fn shrink_right(&self, s: &str) -> Loc<()>
pub fn shrink_right(&self, s: &str) -> Loc<()>
See [shrink_right]
Trait Implementations§
Source§impl<'de, T> Deserialize<'de> for Loc<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for Loc<T>where
T: Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<T> Ord for Loc<T>where
T: Ord,
impl<T> Ord for Loc<T>where
T: Ord,
Source§impl<T> PartialOrd for Loc<T>where
T: PartialOrd,
impl<T> PartialOrd for Loc<T>where
T: PartialOrd,
impl<T: Copy> Copy for Loc<T>
impl<T> Eq for Loc<T>where
T: Eq,
Auto Trait Implementations§
impl<T> Freeze for Loc<T>where
T: Freeze,
impl<T> RefUnwindSafe for Loc<T>where
T: RefUnwindSafe,
impl<T> Send for Loc<T>where
T: Send,
impl<T> Sync for Loc<T>where
T: Sync,
impl<T> Unpin for Loc<T>where
T: Unpin,
impl<T> UnwindSafe for Loc<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
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> Source for T
impl<T> Source for T
Source§type Slice<'a> = <<T as Deref>::Target as Source>::Slice<'a>
where
T: 'a
type Slice<'a> = <<T as Deref>::Target as Source>::Slice<'a> where T: 'a
A type this
Source can be sliced into.Source§fn read<'a, Chunk>(&'a self, offset: usize) -> Option<Chunk>where
Chunk: Chunk<'a>,
fn read<'a, Chunk>(&'a self, offset: usize) -> Option<Chunk>where
Chunk: Chunk<'a>,
Read a chunk of bytes into an array. Returns
None when reading
out of bounds would occur. Read moreSource§unsafe fn read_byte_unchecked(&self, offset: usize) -> u8
unsafe fn read_byte_unchecked(&self, offset: usize) -> u8
Read a byte without doing bounds checks. Read more
Source§fn slice(&self, range: Range<usize>) -> Option<<T as Source>::Slice<'_>>
fn slice(&self, range: Range<usize>) -> Option<<T as Source>::Slice<'_>>
Get a slice of the source at given range. This is analogous to
slice::get(range). Read moreSource§unsafe fn slice_unchecked(
&self,
range: Range<usize>,
) -> <T as Source>::Slice<'_>
unsafe fn slice_unchecked( &self, range: Range<usize>, ) -> <T as Source>::Slice<'_>
Get a slice of the source at given range. This is analogous to
slice::get_unchecked(range). Read more