pub struct Checkpoint<P> { /* private fields */ }Expand description
A checkpoint as returned by Builder::checkpoint, used to wrap
everything added since it was taken with Builder::close_at.
A checkpoint is a Copy index into the builder that handed it out, and the
builder holds its state. Closing it moves it onto the new wrapping node, so
closing it again wraps the wrapper.
§Checkpoints and cloned builders
A cloned Builder clones the state of every checkpoint, so a checkpoint
taken before cloning can be used on both and moves independently in each.
let mut a = syntree::Builder::new();
let c = a.checkpoint()?;
let mut b = a.clone();
b.token("lit", 1)?;
b.close_at(c, "speculative")?;
a.token("lit", 1)?;
a.close_at(c, "root")?;
assert_eq!(a.build()?, syntree::tree! { "root" => { ("lit", 1) } });
assert_eq!(b.build()?, syntree::tree! { "speculative" => { ("lit", 1) } });Trait Implementations§
Source§impl<P> Clone for Checkpoint<P>
impl<P> Clone for Checkpoint<P>
impl<P> Copy for Checkpoint<P>
Source§impl<P> Debug for Checkpoint<P>
impl<P> Debug for Checkpoint<P>
impl<P> Eq for Checkpoint<P>
Auto Trait Implementations§
impl<P> Forget for Checkpoint<P>
impl<P> Freeze for Checkpoint<P>
impl<P> Move for Checkpoint<P>
impl<P> RefUnwindSafe for Checkpoint<P>
impl<P> Send for Checkpoint<P>
impl<P> Sync for Checkpoint<P>
impl<P> Unpin for Checkpoint<P>
impl<P> UnsafeUnpin for Checkpoint<P>
impl<P> UnwindSafe for Checkpoint<P>
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