From 6752ace624c60ca0ee4a251d1001766acad9b4cb Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Tue, 30 Jun 2026 20:56:33 +0100 Subject: Support Rust type paths with generic args --- .../hobgoblin/compiler/output/lang/rust/RustWriterTests.java | 10 ++++++++++ .../output/lang/rust/ast/RustTypePathSegmentMatcher.java | 4 ++++ 2 files changed, 14 insertions(+) (limited to 'src/test/java/org') 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")); + } + 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>> 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 } -- cgit v1.2.3