Open adex-codez opened 2 weeks ago
How do you propose creating an automatic check? I could be missing your question, sorry. But this function (satisfiedBy
) exists on the Interface you create to check:
const Repository = Interface(.{...});
// In functions that accept interface implementations:
fn createUser(repo: anytype, name: []const u8, email: []const u8) !User {
comptime Repository.satisfiedBy(@TypeOf(repo));
// ... rest of implementation
}
// Or verify directly:
comptime Repository.satisfiedBy(InMemoryRepository); // where `InMemoryRepository` is the struct implementing `Repository`
For every type which implements an interface an automatic check for if the type implements the interface like go's interface