Attribute Macro utility_types::pick[][src]

#[pick]
Expand description

Constructs a struct by picking the set of fields from the original struct.

Example

#[pick(ContentComments, [content, comments], [Debug])]
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>
}

#[derive(Debug)]
struct ContentComments<T> {
    content: String,
    comments: T,
}

Notice

Currently, generics are not analyzed. So rustc will complain if the field with generic is not included in the generated struct.