Derive Macro zerocopy::NoCell

source ·
#[derive(NoCell)]
Available on crate feature derive only.
Expand description

Analyzes whether a type is NoCell.

This derive analyzes, at compile time, whether the annotated type satisfies the safety conditions of NoCell and implements NoCell if it is sound to do so. This derive can be applied to structs, enums, and unions; e.g.:

#[derive(NoCell)]
struct MyStruct {
    ...
}

#[derive(NoCell)]
enum MyEnum {
    ...
}

#[derive(NoCell)]
union MyUnion {
    ...
}

§Analysis

This section describes, roughly, the analysis performed by this derive to determine whether it is sound to implement NoCell for a given type. Unless you are modifying the implementation of this derive, or attempting to manually implement NoCell for a type yourself, you don’t need to read this section.

If a type has the following properties, then this derive can implement NoCell for that type:

  • All fields must be NoCell.

This analysis is subject to change. Unsafe code may only rely on the documented safety conditions of NoCell, and must not rely on the implementation details of this derive.