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

kw interface

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

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

Синтаксис

ebnf
Interface   = "interface" Ident [ Generics ] "{" { IMember } "}" ;

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

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

Примеры

oxl
pub(api) interface Storage {
  fn get(k: str) -> bytes?  io
  var fn put(k: str, v: bytes)  io
  fn has(k: str) -> bool  io => get(k) != none     // метод по умолчанию
}

interface ReadWrite { embed Reader; embed Writer }
interface Container<T> { type Item = T; fn items() -> iter<T> }

@explicit interface Persistent { fn key() -> str }

assert FileStorage: Storage                      // статическая проверка

— 4.6 Интерфейсы

oxl
impl Money {
  pub const ZERO: Money = Money{ minor: 0 }
  pub const MAX_TRANSFER: Money = Money.rub(1_000_000)
}

interface Codec<T> { const NAME: str }          // реализация обязана задать значение
impl Codec<Point> for GeoHashCodec { const NAME: str = "geohash" }

— 4.5 impl и методы

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

explicit-interface, interface-not-satisfied, impl-foreign-type, unknown-method, unknown-type, schema-attr, attribute-not-applicable, cache-not-readonly, invalid-window, retry-not-idempotent, rpc-attr

См. также