Skip to content

derive(Clone, Debug, Default)#3

Open
nandoflorestan wants to merge 1 commit into
Boscop:masterfrom
nandoflorestan:derive
Open

derive(Clone, Debug, Default)#3
nandoflorestan wants to merge 1 commit into
Boscop:masterfrom
nandoflorestan:derive

Conversation

@nandoflorestan
Copy link
Copy Markdown
Contributor

I am using Param and ParamDef without using the rest of the library (so far).

When I tried to store Params in an array, Rust complained that it couldn't, for lack of one of these basic traits. If one of them is inappropriate, please enlighten this Rust beginner.

@Boscop
Copy link
Copy Markdown
Owner

Boscop commented Oct 15, 2018

Thanks. I think Clone and Debug make sense to derive but Default doesn't. In which situation do you need it to be Default?
If you have a struct where you derive Default that has a member like Option<Param> or Vec<ParamDef>, I recommend deriving SmartDefault instead, which is smart enough to know that the T doesn't have to be Default (because None and vec![] don't need to instantiate a T).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants