OxL Reference

method Repr.toRepr

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

Example:

oxl✓ checked in 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())
}
Output
ann@example.org
fn toRepr() -> W

Complexity. as the conversion you write.

Since. 1.0.0-beta

Returns

W

Effects

none declared (pure unless the body says otherwise)

Defined in: std/ser/ser.oxl:183

See also