diff options
Diffstat (limited to 'src/main')
3 files changed, 52 insertions, 1 deletions
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/RustWriter.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/RustWriter.java index aa8d6cb..53b9a38 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/RustWriter.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/RustWriter.java @@ -383,6 +383,10 @@ public class RustWriter implements AutoCloseable { this.writeTupleExpression(tupleExpression); } + case RustTypeCastExpression typeCastExpression -> { + this.writeTypeCastExpression(typeCastExpression); + } + case RustVecRepeatExpression vecRepeatExpression -> { this.writeVecRepeatExpression(vecRepeatExpression); } @@ -430,6 +434,7 @@ public class RustWriter implements AutoCloseable { case RustStructExpression _ -> RustPrecedence.PRIMARY; case RustTryPropagationExpression _ -> RustPrecedence.TRY_PROPAGATION; case RustTupleExpression _ -> RustPrecedence.PRIMARY; + case RustTypeCastExpression _ -> RustPrecedence.AS; case RustVecRepeatExpression _ -> RustPrecedence.PRIMARY; }; } @@ -668,6 +673,12 @@ public class RustWriter implements AutoCloseable { this.writer.write(")"); } + private void writeTypeCastExpression(RustTypeCastExpression typeCastExpression) throws IOException { + this.writeSubExpression(typeCastExpression.left(), RustPrecedence.AS, true); + this.writer.write(" as "); + this.writeType(typeCastExpression.right()); + } + private void writeVecRepeatExpression(RustVecRepeatExpression vecRepeatExpression) throws IOException { this.writer.write("vec