pub enum TermPos {
Original(RawSpan),
Inherited(RawSpan),
None,
}Expand description
The position span of a term.
Variants§
Original(RawSpan)
The term exactly corresponds to an original expression in the source, or is a construct introduced by program transformation that corresponds to an original span in the source.
Inherited(RawSpan)
The term is the result of the evaluation of an original expression in the source.
None
The term couldn’t be assigned a position (usually generated during execution or program transformations).
Implementations§
Source§impl TermPos
impl TermPos
Sourcepub fn map<F: FnOnce(RawSpan) -> RawSpan>(self, f: F) -> Self
pub fn map<F: FnOnce(RawSpan) -> RawSpan>(self, f: F) -> Self
Apply a transformation to the inner position, if any.
pub fn as_opt_ref(&self) -> Option<&RawSpan>
pub fn into_opt(self) -> Option<RawSpan>
Sourcepub fn src_id(&self) -> Option<FileId>
pub fn src_id(&self) -> Option<FileId>
Returns the file id associated to this position, if the position is defined, or None
otherwise.
Sourcepub fn or(self, other: Self) -> Self
pub fn or(self, other: Self) -> Self
Return self if self not Self::None, or other otherwise.
Sourcepub fn xor(self, other: Self) -> Self
pub fn xor(self, other: Self) -> Self
Return either self or other if and only if exactly one of them is defined. If both are
None or both are defined, None is returned.
Sourcepub fn is_def(&self) -> bool
pub fn is_def(&self) -> bool
Determine is the position is defined. Return false if it is None, and true otherwise.
Sourcepub fn into_inherited(self) -> Self
pub fn into_inherited(self) -> Self
Try to set the position to inherited, if it wasn’t already. If self was None, None is
returned.
Sourcepub fn fuse(self, other: Self) -> Self
pub fn fuse(self, other: Self) -> Self
Fuse two positions if they are from the same source file.
- If both positions are defined and from the same file, the resulting position is the smallest span that contain both.
- If both positions are defined but aren’t from the same file, this returns
TermPos::None - If at most one position is defined, the other is returned (whether defined or not).
Trait Implementations§
impl Copy for TermPos
impl Eq for TermPos
impl StructuralPartialEq for TermPos
Auto Trait Implementations§
impl Freeze for TermPos
impl RefUnwindSafe for TermPos
impl Send for TermPos
impl Sync for TermPos
impl Unpin for TermPos
impl UnsafeUnpin for TermPos
impl UnwindSafe for TermPos
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§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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>
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>
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