Skip to main content

TypeSift

Derive Macro TypeSift 

Source
#[derive(TypeSift)]
{
    // Attributes available to this derive:
    #[typesift]
}
Expand description

Derives typesift::TypeSift: the value itself is offered first, then each field is visited in declaration order.

Every type parameter gets a TypeSift bound. Types with lifetime parameters are rejected because TypeSift requires 'static types, and unions because the active field is unknown.

Fields accept one argument, and none of them removes the bound on type parameters:

  • #[typesift(skip)] leaves the field out of the traversal, so its type needs no impl.
  • #[typesift(leaf)] offers the field itself but does not look inside it, so its type needs only to be 'static. This is how a type from another crate can still be found.
  • #[typesift(with = path)] hands the field to a function generic over typesift::Sifter, which decides what of it the search sees.