-
Notifications
You must be signed in to change notification settings - Fork 123
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
Add const
to constructors by a feature
#218
Conversation
Should this really be feature-gated? I cannot imagine the situation where |
Just in case you are using a legacy compiler with no support of att. @tyranron |
@fmiguelgarcia well, once we release 1.0 (next release) we will have MSRV set to 1.65, so you won't be able to use legacy compilers 🤷♂️ |
Yes, given we're going dropping support for old rust versions in the next release I think this shouldn't be behind a feature, but should simply be the only behaviour. |
Also, I feel like the same should be done for the |
@JelteF |
…ore into const_constructor
…ore into const_constructor
…ore into const_constructor
@fmiguelgarcia I'd vote for removing |
impl/src/constructor.rs
Outdated
@@ -24,12 +24,14 @@ pub fn expand(input: &DeriveInput, _: &str) -> TokenStream { | |||
_ => panic!("Only structs can derive a constructor"), | |||
}; | |||
let original_types = &get_field_types(&fields); | |||
let fn_signature = quote!( pub const fn new(#(#vars: #original_types),*) -> #input_type #ty_generics ); |
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.
This doesn't have to be a separate variable, I'm guessing this is a leftover from the feature.
Something is weird about the github diff, I'm not sure why but it shows changes introduced in other PRs. You might want to try squashing your commits together and rebasing on top of master. |
I think this is almost good to merge, just a few things are needed:
|
@fmiguelgarcia do you have time to do that? This is one of the final things left on the 1.0.0 milestone. |
Resolves Constructor generated new should be marked const
Synopsis
Added a new
const
feature which generatesconst fn
onConstructor
derives.Solution
Checklist