-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Refactor build-templated-pages/features #12241
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
base: main
Are you sure you want to change the base?
Conversation
You added a new feature but didn't add a description for it. Please update the root Cargo.toml file. |
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 agree that a refactor is due here, but I have a few requests. The main goal is to increase readability and decrease pointless allocations, by using more references and such.
let value = |v: &Value| { | ||
let feature_name = v.as_str().unwrap(); | ||
let feature = |v: &Value| v.as_str().unwrap().to_string(); | ||
let features_to_array = |name| features.get(name).unwrap().as_array().unwrap(); | ||
let map = features_to_array(feature_name).iter().map(feature); | ||
std::iter::once(feature_name.to_string()).chain(map) | ||
}; |
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 is quite difficult to read. Is there a way to refactor this so it is more understandable? (Even better, if you can return impl Iterator<Item = String / &str>
.)
If that's not possible, could you add comments explaining the purpose of this code?
You added a new example but didn't add metadata for it. Please update the root Cargo.toml file. |
You added a new feature but didn't add a description for it. Please update the root Cargo.toml file. |
You added a new feature but didn't add a description for it. Please update the root Cargo.toml file. |
You added a new feature but didn't add a description for it. Please update the root Cargo.toml file. |
Objective
Solution