kw interface
Reserved keyword
The list of words: §1.4
Syntax
Interface = "interface" Ident [ Generics ] "{" { IMember } "}" ;Grammar: App. A
Defined in
- 4.6 Interfaces — Interfaces are structural
- 4.5 impl and methods — Inside a method self and Self are available.
- 3.4 Declared types — data — a product type with named fields (§4.2).
- 9.5 User-defined serialisers — Level 1 — representation through another type (Repr), acts in all formats and in schemas
- 10.2 rpc attributes — Defaults for all rpcs are set in cluster { defaults { …
- 1.4 Keywords — Reserved (cannot be used as names)
Examples
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 // a default method
}
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 // static checkimpl Money {
pub const ZERO: Money = Money{ minor: 0 }
pub const MAX_TRANSFER: Money = Money.rub(1_000_000)
}
interface Codec<T> { const NAME: str } // the implementation must supply a value
impl Codec<Point> for GeoHashCodec { const NAME: str = "geohash" }Related diagnostics
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