pub struct Positioned<T: ?Sized> {
pub pos: Pos,
pub node: T,
}
Expand description
An AST node that stores its original position.
Fields§
§pos: Pos
The position of the node.
node: T
The node itself.
Implementations§
source§impl<T> Positioned<T>
impl<T> Positioned<T>
sourcepub const fn new(node: T, pos: Pos) -> Positioned<T>
pub const fn new(node: T, pos: Pos) -> Positioned<T>
Create a new positioned node from the node and its position.
sourcepub fn into_inner(self) -> T
pub fn into_inner(self) -> T
Get the inner node.
This is most useful in callback chains where Positioned::into_inner
is
easier to read than |positioned| positioned.node
.
sourcepub fn position_node<U>(&self, other: U) -> Positioned<U>
pub fn position_node<U>(&self, other: U) -> Positioned<U>
Create a new positioned node with the same position as this one.
sourcepub fn map<U>(self, f: impl FnOnce(T) -> U) -> Positioned<U>
pub fn map<U>(self, f: impl FnOnce(T) -> U) -> Positioned<U>
Map the inner value of this positioned node.
Trait Implementations§
source§impl BorrowMut<str> for Positioned<String>
impl BorrowMut<str> for Positioned<String>
source§fn borrow_mut(&mut self) -> &mut str
fn borrow_mut(&mut self) -> &mut str
Mutably borrows from an owned value. Read more
source§impl<T: Clone + ?Sized> Clone for Positioned<T>
impl<T: Clone + ?Sized> Clone for Positioned<T>
source§fn clone(&self) -> Positioned<T>
fn clone(&self) -> Positioned<T>
Returns a copy of the value. Read more
1.6.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<T: Default + ?Sized> Default for Positioned<T>
impl<T: Default + ?Sized> Default for Positioned<T>
source§fn default() -> Positioned<T>
fn default() -> Positioned<T>
Returns the “default value” for a type. Read more
source§impl<'de, T> Deserialize<'de> for Positioned<T>where
T: Deserialize<'de> + ?Sized,
impl<'de, T> Deserialize<'de> for Positioned<T>where
T: Deserialize<'de> + ?Sized,
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: Display> Display for Positioned<T>
impl<T: Display> Display for Positioned<T>
source§impl<T: Hash> Hash for Positioned<T>
impl<T: Hash> Hash for Positioned<T>
source§impl<T: Ord> Ord for Positioned<T>
impl<T: Ord> Ord for Positioned<T>
source§impl<T: PartialEq> PartialEq for Positioned<T>
impl<T: PartialEq> PartialEq for Positioned<T>
source§impl<T: PartialOrd> PartialOrd for Positioned<T>
impl<T: PartialOrd> PartialOrd for Positioned<T>
source§impl<T> Serialize for Positioned<T>
impl<T> Serialize for Positioned<T>
impl<T: Copy + ?Sized> Copy for Positioned<T>
impl<T: Eq> Eq for Positioned<T>
Auto Trait Implementations§
impl<T> Freeze for Positioned<T>
impl<T> RefUnwindSafe for Positioned<T>where
T: RefUnwindSafe + ?Sized,
impl<T> Send for Positioned<T>
impl<T> Sync for Positioned<T>
impl<T> Unpin for Positioned<T>
impl<T> UnwindSafe for Positioned<T>where
T: UnwindSafe + ?Sized,
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
)source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
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
Compare self to
key
and return true
if they are equal.