Attribute Macro utility_types::partial[][src]

#[partial]
Expand description

Constructs a struct with all properties of the original struct set to optional.

Example

#[partial(PartialArticle)]
struct Article<T> {
    author: String,
    content: String,
    liked: usize,
    comments: T,
    link: Option<String>
}

The code above will become this:

struct Article<T> {
    author: String,
    content: String,
    liked: usize,
    comments: T,
    link: Option<String>
}

struct PartialArticle<T> {
    author: Option<String>,
    content: Option<String>,
    liked: Option<usize>,
    comments: Option<T>,
    link: Option<Option<String>>
}