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

kw type

Зарезервированное слово

Список слов: §1.4

Синтаксис

ebnf
IMember     = "embed" Type | "type" Ident [ "=" Type ] | Receiver "fn" Sig [ "=>" Expr | Block ] ;
ebnf
TypeAlias   = "type" Ident [ Generics ] "=" ( [ "distinct" ] Type [ "where" Expr ] ) ;

Грамматика: Прил. A

Определяется в

Примеры

oxl
type Bytes2 = [u8; 2]                     // псевдоним, тот же тип
type UserId = distinct u64                // новый тип, без неявных приведений
type Port   = u16 where 1..=65535         // уточнённый тип
type Name   = str where len(1..=64)
type Email  = str where matches(re".+@.+\..+")

— 3.6 Псевдонимы, новые и уточнённые типы

oxl
type NetError = Timeout | Unavailable | Cancelled | AccessDenied | ProtocolError

— 6.5 Ошибки

Связанные диагностики

refinement-violated, comptime-error, not-comptime, fail-type, question-context, unhandled-error, bad-label, explicit-interface, interface-not-satisfied

См. также