diff options
Diffstat (limited to 'src/main/java')
| -rw-r--r-- | src/main/java/org/zwobble/hobgoblin/compiler/output/generators/rusttransient0/RustTransient0Generator.java | 62 |
1 files changed, 31 insertions, 31 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 700b74f..7f1449b 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 @@ -272,37 +272,6 @@ public class RustTransient0Generator implements Generator { ); } - private RustExpression mapErrToInvalidData(RustExpression result) { - return mapErr( - result, - error -> new RustCallExpression( - RustPath.global("std", "io", "Error", "new"), - List.of( - RustPath.global("std", "io", "ErrorKind", "InvalidData"), - RustPath.of(error) - ) - ) - ); - } - - private RustExpression mapErr( - RustExpression result, - Function<RustIdentifier, RustExpression> func - ) { - var error = RustIdentifier.of("error"); - - return methodCall( - result, - RustIdentifier.of("map_err"), - List.of( - new RustClosureExpression( - List.of(new RustIdentifierPattern(error)), - func.apply(error) - ) - ) - ); - } - private RustModule generateNamespace(TypedNamespaceNode namespace) { var namespaceName = namespace.namespaceName(); var moduleName = generateTransient0ModuleName(namespaceName); @@ -903,4 +872,35 @@ public class RustTransient0Generator implements Generator { ) )); } + + private RustExpression mapErrToInvalidData(RustExpression result) { + return mapErr( + result, + error -> new RustCallExpression( + RustPath.global("std", "io", "Error", "new"), + List.of( + RustPath.global("std", "io", "ErrorKind", "InvalidData"), + RustPath.of(error) + ) + ) + ); + } + + private RustExpression mapErr( + RustExpression result, + Function<RustIdentifier, RustExpression> func + ) { + var error = RustIdentifier.of("error"); + + return methodCall( + result, + RustIdentifier.of("map_err"), + List.of( + new RustClosureExpression( + List.of(new RustIdentifierPattern(error)), + func.apply(error) + ) + ) + ); + } } |
