diff options
Diffstat (limited to 'src/main/java/org/zwobble')
2 files changed, 8 insertions, 7 deletions
diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rusttransient0/RustTransient0Generator.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rusttransient0/RustTransient0Generator.java index 3c8000c..b34206e 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rusttransient0/RustTransient0Generator.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rusttransient0/RustTransient0Generator.java @@ -700,7 +700,7 @@ public class RustTransient0Generator implements Generator { List.of( new RustLetStatement(length, false, generateDecode(NativeTypes.INT_64)), new RustLetStatement(elements, true, new RustCallExpression( - RustPath.global("std", "vec", "Vec", "with_capacity"), + RustTypes.VEC.addSegment(RustPathSegment.of("with_capacity")), List.of(tryIntoOrInvalidData(RustPath.of(length))) )), new RustExpressionStatement(new RustIteratorLoopExpression( @@ -728,7 +728,7 @@ public class RustTransient0Generator implements Generator { List.of( new RustMatchArm( new RustTupleStructPattern( - RustPath.global("std", "option", "Option", "Some"), + RustTypes.SOME, List.of(new RustIdentifierPattern(VALUE_NAME)) ), new RustBlockExpression( @@ -749,7 +749,7 @@ public class RustTransient0Generator implements Generator { ) ), new RustMatchArm( - new RustPathPattern(RustPath.global("std", "option", "Option", "None")), + new RustPathPattern(RustTypes.NONE), new RustBlockExpression( List.of( generateEncode( @@ -777,7 +777,7 @@ public class RustTransient0Generator implements Generator { List.of(), Optional.of( new RustCallExpression( - RustPath.global("std", "option", "Option", "Some"), + RustTypes.SOME, List.of(generateDecode(elementType)) ) ) @@ -785,7 +785,7 @@ public class RustTransient0Generator implements Generator { new RustBlockExpression( List.of(), Optional.of( - RustPath.global("std", "option", "Option", "None") + RustTypes.NONE ) ) )) diff --git a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/RustTypes.java b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/RustTypes.java index c0ee970..1dea2b0 100644 --- a/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/RustTypes.java +++ b/src/main/java/org/zwobble/hobgoblin/compiler/output/lang/rust/RustTypes.java @@ -52,8 +52,9 @@ public class RustTypes { return ARC.withArgs(List.of(innerType)); } + public static RustPath VEC = RustPath.global("std", "vec", "Vec"); + public static RustPath vec(RustType elementType) { - return RustPath.global("std", "vec", "Vec") - .withArgs(List.of(elementType)); + return VEC.withArgs(List.of(elementType)); } } |
