Version: 1.1.0

Decorators

Decorators attach behavior to a declaration. They sit on the line above a struct or function and start with @.

Essentials

  • @fieldwise_init generates a constructor.
  • @always_inline and @no_inline control inlining.
  • @deprecated warns callers and can point at the replacement.
  • @implicit allows a converting initializer to run silently.
  • A decorator is resolved at compile time.

Example

@fieldwise_init
struct Pair:
    var a: Int
    var b: Int

Keep in mind

Decorators are not Python runtime wrappers. They change compilation of the declaration they sit on.