nrc / derive-new

derive simple constructor functions for Rust structs
MIT License
525 stars 35 forks source link

Constructor with different name than "new"? #46

Open Boscop opened 5 years ago

Boscop commented 5 years ago

Is it possible to name the ctor differently than "new"? I have several use cases where I use the derived new only internally in my real ctor that should be used by client code. The fact that derive-new names the ctor new means I can't use that name for my handwritten ctor, but I'd like to. Could you add the feature to name it differently? E.g. #[derive(new = "new_internal")]

arnodb commented 4 years ago

We could even optionally remove the "new_" prefix entirely for enums.