From f6d9218df26adb6f377acc6cf1b821dca710f73b Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Tue, 14 Jul 2026 20:01:33 +0100 Subject: Add RustImplTraitType --- .../compiler/output/lang/rust/RustWriterTests.java | 13 ++++++++ .../lang/rust/ast/RustImplTraitTypeMatcher.java | 39 ++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustImplTraitTypeMatcher.java (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 776d51d..da07c8a 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 @@ -460,6 +460,19 @@ public class RustWriterTests { assertThat(string, equalTo("f(x, y)")); } + // == Types == + + @Test + public void implTraitType() throws IOException { + var rust = RustImplTraitType.arbitrary() + .withTrait(RustTypePath.of("std", "io", "Read")) + .build(); + + var string = write(writer -> writer.writeType(rust)); + + assertThat(string, equalTo("impl std::io::Read")); + } + // == Paths == @Test diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustImplTraitTypeMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustImplTraitTypeMatcher.java new file mode 100644 index 0000000..02afb08 --- /dev/null +++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/rust/ast/RustImplTraitTypeMatcher.java @@ -0,0 +1,39 @@ +// Generated by hobgoblin. + +package org.zwobble.hobgoblin.compiler.output.lang.rust.ast; + +// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitTypeMatcher imports +// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitTypeMatcher imports + +public class RustImplTraitTypeMatcher implements org.zwobble.precisely.Matcher { + public static org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitTypeMatcher isRustImplTraitType() { + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitTypeMatcher(java.util.List.of()); + } + + private final java.util.List> submatchers; + + private RustImplTraitTypeMatcher(java.util.List> submatchers) { + this.submatchers = submatchers; + } + + public org.zwobble.precisely.MatchResult match(java.lang.Object actual) { + return this.toMatcher().match(actual); + } + + public org.zwobble.precisely.TextTree describe() { + return this.toMatcher().describe(); + } + + private org.zwobble.precisely.Matcher toMatcher() { + return org.zwobble.precisely.Matchers.instanceOf(org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitType.class, this.submatchers); + } + + public org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitTypeMatcher withTrait(org.zwobble.precisely.Matcher trait) { + var submatchers = new java.util.ArrayList>(this.submatchers); + submatchers.add(org.zwobble.precisely.Matchers.has("trait", org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitType::trait, trait)); + return new org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitTypeMatcher(submatchers); + } + + // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitTypeMatcher body + // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.rust.ast.RustImplTraitTypeMatcher body +} -- cgit v1.2.3