select

Macro select 

Source
macro_rules! select {
    ($($module:ident)::+ : .. $spread:ty) => { ... };
    ($($module:ident)::+ :) => { ... };
    ($($module:ident)::+ : $field:ident, .. $spread:ty) => { ... };
    ($($module:ident)::+ : $field:ident ?, .. $spread:ty) => { ... };
    ($($module:ident)::+ : $field:ident -, .. $spread:ty) => { ... };
    ($($module:ident)::+ : $field:ident < $presence:ty >, .. $spread:ty) => { ... };
    ($($module:ident)::+ : $field:ident) => { ... };
    ($($module:ident)::+ : $field:ident,) => { ... };
    ($($module:ident)::+ : $field:ident ?) => { ... };
    ($($module:ident)::+ : $field:ident ?,) => { ... };
    ($($module:ident)::+ : $field:ident -) => { ... };
    ($($module:ident)::+ : $field:ident -,) => { ... };
    ($($module:ident)::+ : $field:ident < $presence:ty >) => { ... };
    ($($module:ident)::+ : $field:ident < $presence:ty >,) => { ... };
    ($($module:ident)::+ : $field:ident ?, $($rest:tt)+) => { ... };
    ($($module:ident)::+ : $field:ident -, $($rest:tt)+) => { ... };
    ($($module:ident)::+ : $field:ident < $presence:ty >, $($rest:tt)+) => { ... };
    ($($module:ident)::+ : $field:ident, $($rest:tt)+) => { ... };
}
Expand description

Construct a FieldSet by selecting fields from a module.

§Syntax

  • select!(module: field) - field is Present
  • select!(module: field?) - field is Optional
  • select!(module: field-) - field is Absent
  • select!(module: field<Type>) - field has custom presence type
  • select!(module: all?) - all fields Optional
  • select!(module: all-) - all fields Absent
  • select!(module: field, ..F) - field is Present, remaining fields from F
  • Multiple fields compose: select!(module: field1, field2?) expands to module::with::field1<Present, module::with::field2<Optional>>

§Examples

ⓘ
type Create = select!(user: name, email);
type Update = select!(user: name?, email?);
type WithId<F: user::Fields> = select!(user: id, ..F);
fn create_user(user: User<Create>) {...}