OxL Reference

kw data

Reserved keyword

The list of words: §1.4

Syntax

ebnf
Data        = "data" Ident [ Generics ] [ Where ] "{" { Member } "}" ;

Grammar: App. A

Defined in

Examples

oxl
pub(api) data User {
  pub(api) id: UserId
  pub(api) name: Name
  pub(api) email: Email?           @since(2)
  role: Role = Role.User
  createdAt: Time = now()
  invariant name != "admin" || role == Role.Admin
}

— 4.2 data

oxl
fn max<T>(a: T, b: T) -> T where T: Ord => if a > b { a } else { b }
data Page<T> where T: Serializable { items: List<T>; next: Cursor? }
data Matrix<const R: usize, const C: usize> { cells: [f64; R * C] }
fn pack<T>(x: T) -> bytes where T: Serializable, size_of(T) <= 4KiB
data Cache<K: Hash + Eq, V = bytes> { … }

— 4.8 Generics

Related diagnostics

unknown-field, bound-not-satisfied, generic-args, schema-attr, bad-init, missing-field, must-close, positional-literal, sealed-literal, ambiguous-embed, missing-override, override-without-open, fail-type, question-context

See also