[][src]Macro drop_move::drop_move_wrap

macro_rules! drop_move_wrap {
    {$($def:tt)+} => { ... };
}

Generate a pair of structures to allow moving out of drop.

The syntax is roughly:

#[shared_attributes]
{
    #[outer_only_attributes]
}
outer_visibility struct outer_name<...>(
    #[inner_only_attributes] inner_visibility inner_structure {
        members
    }
) where ...;

Tuple structs can be used by swapping { members } for ( members ), and enumerations by changing struct to enum. The attributes, generic parameters, and where clause are optional and can be omitted. The syntax for the generic parameters and bounds is almost the same as normal; however, due to limitations in macro parsing they do not support the + syntax for specifying multiple traits. Instead, you should use :, so e.g. T: Clone : Eq means that T must implement both Clone and Eq.

The macro expands to two structures: struct outer_name wrapping a DropMoveWrapper containing struct inner_name, which holds the actual members. All attributes in shared_attributes are applied to both. Doc comments are also attributes, and can also be used here. The inner visibility is applied to both the definition of the inner struct and the field of the outer struct that wraps it, so if it is pub then anyone will be able to access it.

This macro also implements From to convert back and forth between the inner and outer structures, and DropMoveTypes to tell DropMoveWrapper the relationship between the inner and outer structures.

Note that this macro is implemented internally using a few others, which may appear in compiler error messages. These all have names prefixed with drop_move_wrap.