pub struct TopSubtreeBuilder {
unclosed_subtree_indices: Vec<usize>,
token_trees: TopSubtreeBuilderRepr,
span_parts: IndexSet<CompressedSpanPart, FxBuildHasher>,
last_closed_subtree: Option<usize>,
top_subtree_spans: DelimSpan,
}Fields§
§unclosed_subtree_indices: Vec<usize>§token_trees: TopSubtreeBuilderRepr§span_parts: IndexSet<CompressedSpanPart, FxBuildHasher>§last_closed_subtree: Option<usize>§top_subtree_spans: DelimSpanWe need to keep those because they are not inside span_parts, see RESERVED_SPAN_PARTS_LEN.
Implementations§
Source§impl TopSubtreeBuilder
impl TopSubtreeBuilder
pub fn new(top_delimiter: Delimiter) -> Self
fn span_part_index(&mut self, part: CompressedSpanPart) -> usize
fn switch_repr<T: SpanStorage, U: From<T>>( repr: &mut Vec<TokenTree<T>>, ) -> Vec<TokenTree<U>>
Sourcefn ensure_can_hold(&mut self, text_range: TextRange, span_parts_index: usize)
fn ensure_can_hold(&mut self, text_range: TextRange, span_parts_index: usize)
Ensures we have a representation that can hold these values.
Sourcefn push_subtree(&mut self, subtree: Subtree)
fn push_subtree(&mut self, subtree: Subtree)
Not to be exposed, this assumes the subtree’s children will be filled in immediately.
pub fn open(&mut self, delimiter_kind: DelimiterKind, open_span: Span)
pub fn close(&mut self, close_span: Span)
Sourcepub fn remove_last_subtree_if_invisible(&mut self)
pub fn remove_last_subtree_if_invisible(&mut self)
You cannot call this consecutively, it will only work once after close.
fn push_literal(&mut self, leaf: Literal)
fn push_punct(&mut self, leaf: Punct)
fn push_ident(&mut self, leaf: Ident)
pub fn push(&mut self, leaf: Leaf)
fn push_token_tree(&mut self, tt: TokenTree)
pub fn extend(&mut self, leaves: impl IntoIterator<Item = Leaf>)
pub fn extend_with_tt(&mut self, tt: TokenTreesView<'_>)
Sourcepub fn extend_with_tt_alone(&mut self, tt: TokenTreesView<'_>)
pub fn extend_with_tt_alone(&mut self, tt: TokenTreesView<'_>)
Like Self::extend_with_tt(), but makes sure the new tokens will never be
joint with whatever comes after them.
pub fn expected_delimiters(&self) -> impl Iterator<Item = DelimiterKind>
Sourcepub fn build_skip_top_subtree(self) -> TopSubtree
pub fn build_skip_top_subtree(self) -> TopSubtree
Builds, and remove the top subtree if it has only one subtree child.
pub fn build(self) -> TopSubtree
pub fn restore_point(&self) -> SubtreeBuilderRestorePoint
pub fn restore(&mut self, restore_point: SubtreeBuilderRestorePoint)
Trait Implementations§
Source§impl Clone for TopSubtreeBuilder
impl Clone for TopSubtreeBuilder
Source§fn clone(&self) -> TopSubtreeBuilder
fn clone(&self) -> TopSubtreeBuilder
Returns a duplicate 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 moreAuto Trait Implementations§
impl Freeze for TopSubtreeBuilder
impl !RefUnwindSafe for TopSubtreeBuilder
impl Send for TopSubtreeBuilder
impl Sync for TopSubtreeBuilder
impl Unpin for TopSubtreeBuilder
impl !UnwindSafe for TopSubtreeBuilder
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,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
Converts
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