Skip to content

Commit

Permalink
add casting to formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
kevaundray committed Oct 5, 2023
1 parent a38b15f commit a8db779
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tooling/nargo_fmt/src/visitor/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ impl FmtVisitor<'_> {
ExpressionKind::Prefix(prefix) => {
format!("{}{}", prefix.operator, self.format_expr(prefix.rhs))
}
// TODO:
ExpressionKind::Cast(cast) => {
format!("{} as {}", self.format_expr(cast.lhs), cast.r#type)
}
_expr => slice!(self, span.start(), span.end()).to_string(),
}
}
Expand Down
3 changes: 3 additions & 0 deletions tooling/nargo_fmt/tests/expected/cast.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
x as u8
}
3 changes: 3 additions & 0 deletions tooling/nargo_fmt/tests/input/cast.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
x as u8
}

0 comments on commit a8db779

Please sign in to comment.