Skip to content

Feature request: please consider implementing new() constructor and Default trait #293

Closed
@lucatrv

Description

@lucatrv

I know that this has been discussed before, but please consider what suggested in the Rust API guidelines:

https://rust-lang-nursery.github.io/api-guidelines/interoperability.html

Note that it is common and expected for types to implement both Default and an empty new constructor. new is the constructor convention in Rust, and users expect it to exist, so if it is reasonable for the basic constructor to take no arguments, then it should, even if it is functionally identical to default.

https://rust-lang-nursery.github.io/api-guidelines/predictability.html

Note that it is common and expected for types to implement both Default and a new constructor. For types that have both, they should have the same behavior. Either one may be implemented in terms of the other.

For a time type, I think its natural default value should be 0. For a date type, IMHO day 1 of month 1 of year 0 is a reasonable default value as well. Being able to derive the Default trait when defining a custom type which includes a chrono type would of course be very convenient.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions