diff options
| author | Michael Williamson <mike@zwobble.org> | 2026-07-24 14:52:18 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2026-07-24 14:52:18 +0100 |
| commit | 726791a4d40ffdf940c5882e2700e60dff594de3 (patch) | |
| tree | b67694315e4435c85ef62d57843a7fbfe2ce4b7b /src/main/java/org/zwobble | |
| parent | b00bf672cbbd9ff1ec013a52ddfd59fdf82f8144 (diff) | |
Move mapErr methods to end of class
Diffstat (limited to 'src/main/java/org/zwobble')
| -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) + ) + ) + ); + } } |
