#[derive(Required)]
{
// Attributes available to this derive:
#[required]
}
Expand description
Constructs a struct with all fields of the original struct set to required.
§Example
#[derive(Required)]
#[required(ident = RequiredArticle, derive(Debug))]
pub struct Article {
author: String,
content: Option<String>,
}The above code will generate the following struct:
#[derive(Debug)]
pub struct RequiredArticle {
author: String,
content: String,
}§Attributes
ⓘ
#[derive(Required)]
#[required(
ident = <IDENT>, // The identifier of the generated struct
[derive(<DERIVE>, ...)], // Derive attributes for the generated struct
[forward_attrs(<ATTR, ...> | not(<ATTR, ...>))], // Forward specific attributes to the generated struct
)]
pub struct BasedStruct {
#[required(
[forward_attrs(<ATTR, ...> | not(<ATTR, ...>))], // Forward specific attributes to the generated field
// If given, will override the container level `forward_attrs`
)]
field: FieldType,
}