pub struct Checkpoint<P>(/* private fields */)
where
P: Copy;Expand description
The identifier of a node as returned by functions such as
Builder::checkpoint.
This can be used as a checkpoint in Builder::close_at, and a checkpoint
can be fetched up front from Builder::checkpoint.
§Checkpoints and cloned builders
A checkpoint belongs to the builder that handed it out, and closing it
updates it in place. A cloned Builder hands out its own checkpoints, so
one taken from the clone can be used on it without affecting the original.
A checkpoint taken before cloning still belongs to the original: closing
it on the clone updates it for the original too, so get a fresh checkpoint
from the clone instead.
let mut a = syntree::Builder::new();
let c = a.checkpoint()?;
let mut b = a.clone();
let c2 = b.checkpoint()?;
b.token("lit", 1)?;
b.close_at(&c2, "speculative")?;
a.token("lit", 1)?;
a.close_at(&c, "root")?;
assert_eq!(a.build()?, syntree::tree! { "root" => { ("lit", 1) } });Trait Implementations§
Source§impl<P> Clone for Checkpoint<P>
impl<P> Clone for Checkpoint<P>
Auto Trait Implementations§
impl<P> !RefUnwindSafe for Checkpoint<P>
impl<P> !Send for Checkpoint<P>
impl<P> !Sync for Checkpoint<P>
impl<P> !UnwindSafe for Checkpoint<P>
impl<P> Forget for Checkpoint<P>
impl<P> Freeze for Checkpoint<P>
impl<P> Move for Checkpoint<P>
impl<P> Unpin for Checkpoint<P>
impl<P> UnsafeUnpin 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