diff options
| author | Michael Williamson <mike@zwobble.org> | 2026-06-30 20:56:33 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2026-06-30 20:56:33 +0100 |
| commit | 6752ace624c60ca0ee4a251d1001766acad9b4cb (patch) | |
| tree | ca0dd0cc3186fcf55fd95c4ed940ca954f0a655a /src/test/java | |
| parent | f55983f8a5fefe039df83fc601679fc32e04581e (diff) | |
Support Rust type paths with generic args
Diffstat (limited to 'src/test/java')
2 files changed, 14 insertions, 0 deletions
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/RustWriterTests.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/RustWriterTests.java index eca8685..f52d275 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/RustWriterTests.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/RustWriterTests.java @@ -95,6 +95,16 @@ public class RustWriterTests { assertThat(string, equalTo("std::string::String")); } + @Test + public void typeSegmentGenericArgsAreWritten() throws IOException { + var rust = RustTypePath.of("std", "collections", "HashMap") + .withArgs(List.of(RustTypePath.of("i32"), RustTypePath.of("f64"))); + + var string = write(writer -> writer.writeType(rust)); + + assertThat(string, equalTo("std::collections::HashMap<i32, f64>")); + } + private String write(Write write) throws IOException { return write(write, Optional.empty()); } diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTypePathSegmentMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTypePathSegmentMatcher.java index 4a73997..ebefac9 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTypePathSegmentMatcher.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustTypePathSegmentMatcher.java @@ -32,6 +32,10 @@ public class RustTypePathSegmentMatcher implements org.zwobble.precisely.Matcher return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegmentMatcher(java.util.stream.Stream.concat(this.submatchers.stream(), java.util.stream.Stream.of(org.zwobble.precisely.Matchers.has("pathIdentSegment", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment::pathIdentSegment, pathIdentSegment))).toList()); } + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegmentMatcher withArgs(org.zwobble.precisely.Matcher<? super java.util.Optional<java.util.List<org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustType>>> args) { + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegmentMatcher(java.util.stream.Stream.concat(this.submatchers.stream(), java.util.stream.Stream.of(org.zwobble.precisely.Matchers.has("args", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegment::args, args))).toList()); + } + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegmentMatcher body // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustTypePathSegmentMatcher body } |
