refactor(11422): make number unsigned, nest enums into each other
This commit is contained in:
@@ -247,7 +247,7 @@ fn eq_label_lt(lt1: &Option<ast::Lifetime>, lt2: &Option<ast::Lifetime>) -> bool
|
|||||||
|
|
||||||
struct TreeWithDepthIterator {
|
struct TreeWithDepthIterator {
|
||||||
preorder: Preorder<RustLanguage>,
|
preorder: Preorder<RustLanguage>,
|
||||||
depth: i32,
|
depth: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TreeWithDepthIterator {
|
impl TreeWithDepthIterator {
|
||||||
@@ -258,33 +258,31 @@ impl TreeWithDepthIterator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Iterator for TreeWithDepthIterator {
|
impl<'a> Iterator for TreeWithDepthIterator {
|
||||||
type Item = (ast::Expr, i32);
|
type Item = (ast::Expr, u32);
|
||||||
|
|
||||||
fn next(&mut self) -> Option<Self::Item> {
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
while let Some((event, expr)) = self.preorder.find_map(|ev| match ev {
|
while let Some(event) = self.preorder.find_map(|ev| match ev {
|
||||||
WalkEvent::Enter(it) => Some(WalkEvent::Enter(())).zip(ast::Expr::cast(it)),
|
WalkEvent::Enter(it) => ast::Expr::cast(it).map(WalkEvent::Enter),
|
||||||
WalkEvent::Leave(it) => Some(WalkEvent::Leave(())).zip(ast::Expr::cast(it)),
|
WalkEvent::Leave(it) => ast::Expr::cast(it).map(WalkEvent::Leave),
|
||||||
}) {
|
}) {
|
||||||
match (event, expr) {
|
match event {
|
||||||
(
|
WalkEvent::Enter(
|
||||||
WalkEvent::Enter(_),
|
|
||||||
ast::Expr::LoopExpr(_) | ast::Expr::WhileExpr(_) | ast::Expr::ForExpr(_),
|
ast::Expr::LoopExpr(_) | ast::Expr::WhileExpr(_) | ast::Expr::ForExpr(_),
|
||||||
) => {
|
) => {
|
||||||
self.depth += 1;
|
self.depth += 1;
|
||||||
}
|
}
|
||||||
(
|
WalkEvent::Leave(
|
||||||
WalkEvent::Leave(_),
|
|
||||||
ast::Expr::LoopExpr(_) | ast::Expr::WhileExpr(_) | ast::Expr::ForExpr(_),
|
ast::Expr::LoopExpr(_) | ast::Expr::WhileExpr(_) | ast::Expr::ForExpr(_),
|
||||||
) => {
|
) => {
|
||||||
self.depth -= 1;
|
self.depth -= 1;
|
||||||
}
|
}
|
||||||
(WalkEvent::Enter(_), ast::Expr::BlockExpr(e)) if e.label().is_some() => {
|
WalkEvent::Enter(ast::Expr::BlockExpr(e)) if e.label().is_some() => {
|
||||||
self.depth += 1;
|
self.depth += 1;
|
||||||
}
|
}
|
||||||
(WalkEvent::Leave(_), ast::Expr::BlockExpr(e)) if e.label().is_some() => {
|
WalkEvent::Leave(ast::Expr::BlockExpr(e)) if e.label().is_some() => {
|
||||||
self.depth -= 1;
|
self.depth -= 1;
|
||||||
}
|
}
|
||||||
(WalkEvent::Enter(_), expr) => return Some((expr, self.depth)),
|
WalkEvent::Enter(expr) => return Some((expr, self.depth)),
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user