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

method Repr.toRepr

The value as its representation W; called when the type is encoded.

Example:

oxl✓ проверяется в CI
use std.ser { Repr, DecodeError }

@repr(str)
data Email { text: str }

impl Repr<str> for Email {
  fn toRepr() -> str => text.lower()
  static fn fromRepr(v: str) -> Email | DecodeError => Email{ text: v }
}

fn main() io {
  print(Email{ text: "Ann@Example.org" }.toRepr())
}
Вывод
ann@example.org
fn toRepr() -> W

Сложность. as the conversion you write.

С версии. 1.0.0-beta

Возвращает

W

Эффекты

не объявлены (чистая, пока тело не говорит иное)

Определено в: std/ser/ser.oxl:183

См. также