Skip to content

Implement trait utility#5

Merged
Word30210 merged 6 commits into
mainfrom
word30210/feat-trait
May 14, 2026
Merged

Implement trait utility#5
Word30210 merged 6 commits into
mainfrom
word30210/feat-trait

Conversation

@Word30210
Copy link
Copy Markdown
Contributor

What

  • Add src/std/trait/init.luau - a trait utility for defining and implementing Rust-style traits:
    • define(defaults) - declares a trait from its table of default-method implementations
    • impl(methods, trait) - checks an implementer's method table against the trait's required-method contract, then copies the default methods in
  • Add tests/std/trait/.spec.luau - runtime tests for define / impl
  • Add tests/std/trait/.check.luau - type-level tests for the required-method contract

Why

rusty-luau ports Rust idioms, and traits are a foundational one. This PR lands just the core define / impl primitives so later traits can build on them. Conventions documentation and worked examples are intentionally left out for now - they'll be revisited once more traits (Display, Iter<T>, ...) are implemented.

Checklist

Required

  • lute run ./scripts/checker.luau -- ./src ./tests ./scripts passes
  • lute run ./scripts/tester.luau passes

Closes #3.

Functional Validation

  • Tests cover the changed behavior (.spec.luau and .check.luau both added)
  • Both happy and edge paths verified where applicable

Configuration & Docs

  • User-facing docs were updated where applicable - N/A (no README / CLAUDE.md change; trait conventions doc deferred to a later PR)
  • New dependencies / configuration are reflected in pesde.toml / mise.toml - N/A (none added)
  • No sensitive values or credentials were introduced

If Applicable

  • Breaking type-surface or API changes are clearly described - N/A (new module, no existing API touched)

@Word30210 Word30210 self-assigned this May 14, 2026
@Word30210 Word30210 merged commit 5fab460 into main May 14, 2026
2 checks passed
@Word30210 Word30210 deleted the word30210/feat-trait branch May 14, 2026 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Rust's Trait

1 participant