E0306: Bound is not an interface
| Code | Category | Stability |
|---|---|---|
E0306 | Semantic | Permanent |
Explanation
A conformance assertion, refinement, or interface bound names an entity that is not an interface. An ordinary concrete type cannot be used as an interface requirement.
Likely cause
A struct, enum, or primitive type was supplied where an interface name is required. Use a declared interface, or use comptime T: type for an unbounded type parameter.
Examples
Concrete type used as a bound
Requires --preview interfaces.
struct Concrete {}
fn accept(comptime T: Concrete, borrow x: T) {}
fn main() {}
Use an interface bound
Requires --preview interfaces.
interface Marker { fn mark(borrow self); }
fn accept(comptime T: Marker, borrow x: T) {}
fn main() {}