Macro rustifact::write_fns

source ·
macro_rules! write_fns {
    (public, $id_group:ident, $t:ty, $ids_data:expr) => { ... };
    (private, $id_group:ident, $t:ty, $ids_data:expr) => { ... };
}
Expand description

Write a collection of getter functions returning a common type.

Makes the getter functions available for import into the main crate via use_symbols.

Parameters

  • public or private: whether to make the functions publicly visible after import with use_symbols.
  • $id_group: the group alias by which these functions are referred when importing with use_symbols.
  • $t: the (common) return type of the getter functions.
  • $ids_data: The list of type &[(I, $t)] where $t is as above, and I is a type implementing Display, though most commonly String or &’static str. This is a list of identifiers for the functions paired with their values.

Notes

  • Intended for heap-allocated data. For stack-allocated data, consider write_consts or write_static instead.
  • Rather than passing identifiers directly, they are passed as string (in fact Display-implementing) types. It is anticipated that this will be more convenient in the typical use cases of the write_Xs family of macros.