OxL Справочник OxL
РусскийEnglish

data AttrArg

An argument of an attribute: @retry(max: 3) has name "max", kind "int" and text "3".

Example:

oxl✓ проверяется в CI
use std.comptime { Decl, warn }

comptime fn retry_budget(d: Decl) {
  for a in d.attrs {
    if a.name == "retry" {
      for arg in a.args {
        if arg.name == "max" && arg.kind == "int" && arg.text != "3" {
          warn(arg.span, "retry max is {arg.text}")
        }
      }
    }
  }
}
pub(api) data AttrArg

С версии. 1.0.0-beta

Поля

pub(api) name: str

Name of the argument (max in @retry(max: 3)); empty for a positional argument.

pub(api) kind: str

Kind of the value: int, string, bool, ... as lower-case text.

pub(api) text: str

The value as written in the source.

pub(api) span: Span

Where the argument is written.

Определено в: std/comptime/comptime.oxl:69

См. также