iyi

Standard library, 0.18.0

std/derives

Derives, as a library module (SPEC.md R-5, II.4).

import std/derives to use it. Source: src/std/derives.iyi at v0.18.0.

A derive is an exported macro that takes one argument: the declaration it is attached to. It reads that declaration's name and its fields, each field with the type it was written as. It never sees a type it was not given, and it never runs in the consumer.

describedmacro

Renders a value as its type name and its fields. One macro, any declaration: the fields come from whichever type the derive is written in.

std/derivesiyi doc src/std/derives.iyi
pub macro described(declaration)

shownmacro

The question II.4 is about: whether a field's type implements a trait. Only the fields that answer yes are rendered, and each one is rendered by calling the trait's method. A field whose type this macro cannot see answers nil.

std/derivesiyi doc src/std/derives.iyi
pub macro shown(declaration)

Namestruct

A type this module exports, implementing a trait this module exports. A derive in another module gets to ask about both, and both arrive from this module's .iyimod when its source is gone.

std/derivesiyi doc src/std/derives.iyi
pub struct Name
  def initialize(text : String)
end

Showtrait

std/derivesiyi doc src/std/derives.iyi
pub trait Show
  abstract def show : String
end

Show for Nameimpl

std/derivesiyi doc src/std/derives.iyi
impl Show for Name
  def show : String
end