-
Notifications
You must be signed in to change notification settings - Fork 244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: replace usage of new()
with default()
#875
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm unsure of this refactoring - I don't think it improves readability by much and don't think we should strictly follow a style guide even for small items.
In regards to having both T::new
and T::default
, my preference would be to only having T::default
(if it can be automatically derived, or it is required for a T: Default
bound), or T::new
otherwise. No need to have 2 functions that do the same thing.
If new does not do anything special, I am OK to replace it with default, it enables other types to automatically derive if they use one with default. I also agree that in that case we can keep only default and not have both. |
fa49d1f
to
150f3e8
Compare
didn't mean to remove review request @guipublic @kevaundray |
Head branch was pushed to by a user without write access
new()
with default()
Related issue(s)
Related to #874
Description
See
Constructors
section of the guide in the issueSummary of changes
impl Default
tonew()
functions that do not take inputs.new()
to call the default function. (update: remove empty new())// 3.
vec![]
toVec::new()
(discarded this change)// I'm not sure if removing
new()
functions is a good idea (this seems to be what the guide is suggesting from my //understanding) so I changed them to calling thedefault
function.Dependency additions / changes
Test additions / changes
Checklist
cargo fmt
with default settings.Additional context