Skip to content

Automatic interface satisfying check #2

Closed

Description

@adex-codez

For every type which implements an interface an automatic check for if the type implements the interface like go's interface

Activity

  1. nilslice commented on Nov 21, 2024

    @nilslice
    Owner

    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`
  2. nilslice commented on Oct 28, 2025

    @nilslice
    Owner

    @adex-codez - the latest updates should be much more aligned to automatically check (still a small step to construct/convert into the interface type from a concrete impl). Check it out and lmk what you think. PR at #9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions