Enum linked_syntax_tree::Predecessor
source · pub enum Predecessor<T> {
Parent(T),
Previous(T),
}
Expand description
A statement in an AST may have:
- A previous statement
- A next statement
- A child statement
- A parent statement
Consider the example:
x = -10
loop
x = x + 1
if x
break
x = 2
this can be represented as:
┌──────────┐
│x = -10 │
└──────────┘
│
┌──────────┐
│loop │
└──────────┘
│ ╲
┌──────────┐ ┌─────────┐
│x = 2 │ │x = x + 1│
└──────────┘ └─────────┘
│
┌─────────┐
│if x │
└─────────┘
╲
┌─────────┐
│break │
└─────────┘
this is a simplified tree structure.
Variants§
Implementations§
source§impl<T> Predecessor<T>
impl<T> Predecessor<T>
sourcepub fn as_ref(&self) -> Predecessor<&T>
pub fn as_ref(&self) -> Predecessor<&T>
Returns Predecessor<&T>
.
sourcepub fn as_mut(&mut self) -> Predecessor<&mut T>
pub fn as_mut(&mut self) -> Predecessor<&mut T>
Returns Predecessor<&mut T>
.
sourcepub fn map<P>(self, f: impl Fn(T) -> P) -> Predecessor<P>
pub fn map<P>(self, f: impl Fn(T) -> P) -> Predecessor<P>
Maps to Predecessor<P>
.
Trait Implementations§
source§impl<T: Clone> Clone for Predecessor<T>
impl<T: Clone> Clone for Predecessor<T>
source§fn clone(&self) -> Predecessor<T>
fn clone(&self) -> Predecessor<T>
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<T: Debug> Debug for Predecessor<T>
impl<T: Debug> Debug for Predecessor<T>
source§impl<T: PartialEq> PartialEq<Predecessor<T>> for Predecessor<T>
impl<T: PartialEq> PartialEq<Predecessor<T>> for Predecessor<T>
source§fn eq(&self, other: &Predecessor<T>) -> bool
fn eq(&self, other: &Predecessor<T>) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl<T: Copy> Copy for Predecessor<T>
impl<T: Eq> Eq for Predecessor<T>
impl<T> StructuralEq for Predecessor<T>
impl<T> StructuralPartialEq for Predecessor<T>
Auto Trait Implementations§
impl<T> RefUnwindSafe for Predecessor<T>where T: RefUnwindSafe,
impl<T> Send for Predecessor<T>where T: Send,
impl<T> Sync for Predecessor<T>where T: Sync,
impl<T> Unpin for Predecessor<T>where T: Unpin,
impl<T> UnwindSafe for Predecessor<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