pub(crate) struct ExitRewriter<'a> {
chain: &'a Lifetime,
tag: String,
krate: &'a TokenStream,
pub slots: Slots,
local_labels: Vec<String>,
loop_depth: usize,
deferring: bool,
}Expand description
Rewrites the early exits of one node to record-and-stop. Closures, async blocks and nested items keep their own exits; loops and labeled blocks inside the node keep exits aimed at them.
Fields§
§chain: &'a LifetimeThe chain’s label, the target of every rewritten exit.
tag: StringUnique prefix for this node’s slot names.
krate: &'a TokenStream§slots: Slots§local_labels: Vec<String>§loop_depth: usize§deferring: boolRewriting statements of a loop’s first part (fission): chain labels that loop, which is
stopped with a plain break, and exits aimed at it stay as written.
Implementations§
Source§impl<'a> ExitRewriter<'a>
impl<'a> ExitRewriter<'a>
Sourcepub fn new(chain: &'a Lifetime, tag: String, krate: &'a TokenStream) -> Self
pub fn new(chain: &'a Lifetime, tag: String, krate: &'a TokenStream) -> Self
Exits stop the chain labeled chain (break 'chain None).
Sourcepub fn deferring(
chain: &'a Lifetime,
tag: String,
krate: &'a TokenStream,
) -> Self
pub fn deferring( chain: &'a Lifetime, tag: String, krate: &'a TokenStream, ) -> Self
Exits that leave the loop labeled chain stop it and are recorded; continue and
break aimed at that loop stay as written.
Sourcefn targets_own_loop(&self, label: Option<&Lifetime>) -> bool
fn targets_own_loop(&self, label: Option<&Lifetime>) -> bool
True when a break/continue targets the loop being split, so it stays as written.
fn leaves(&self, label: Option<&Lifetime>) -> bool
fn nested(&mut self, label: Option<String>, f: impl FnOnce(&mut Self))
Sourcefn record(&self, slot: &Ident, value: TokenStream) -> Expr
fn record(&self, slot: &Ident, value: TokenStream) -> Expr
{ slot = Some(value); break 'chain None } (a plain break 'chain when deferring).