style-guide icon indicating copy to clipboard operation
style-guide copied to clipboard

rust/functions: constructors

Open nrc opened this issue 6 years ago • 0 comments

default or new (or both).

@BusyJay states: "I personally find Default trait is ambiguous. It can hint that the item is singleton but it's not. On the other hand, it makes things complicated that it adds two different construct conventions, new() and default(). People need to think and find which to use"

Another point is if new should be used for any constructor or only for those that do a fairly straightforward field initialization (like derive-new does).

nrc avatar Nov 18 '19 20:11 nrc