-
Notifications
You must be signed in to change notification settings - Fork 0
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
Use field access syntax in enum macros #1
Use field access syntax in enum macros #1
Conversation
Using struct expression and patterns is allowed in rust for tuple structs. As per references. This allows us to simplify some of the macros, and remove `underscores` from the utility module. - https://play.rust-lang.org/?gist=fd4cc2283fff6a6aade5dbe9427e44db - https://doc.rust-lang.org/reference/expressions/struct-expr.html - https://doc.rust-lang.org/reference/patterns.html#struct-patterns
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.
Definitely much cleaner. Left a few suggestions (feel free to dispute them if you feel strongly about them, though).
Nice suggestions! I'll update this tomorrow. |
Applied all your suggestions |
d4df183
to
9f10360
Compare
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.
Looks good to me! Great work!
/// Returns a `Member` made of `ident` or `index` if `ident` is None. | ||
/// | ||
/// Rust struct syntax allows for `Struct { foo: "string" }` with explicitly | ||
/// named fields. It allows the `Struct { 0: "string" }` syntax when the struct | ||
/// is declared as a tuple struct. | ||
/// | ||
/// ``` | ||
/// # fn main() { | ||
/// struct Foo { field: &'static str } | ||
/// struct Bar(&'static str); | ||
/// let Foo { field } = Foo { field: "hi" }; | ||
/// let Bar { 0: field } = Bar { 0: "hello" }; | ||
/// let Bar(field) = Bar("hello"); // more common syntax | ||
/// # } | ||
/// ``` | ||
/// | ||
/// This function helps field access in context where you are declaring either | ||
/// a tuple struct or a struct with named fields. If you don't have a field name, | ||
/// it means you need to access the struct through an index. |
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.
Awesome docs. Thank you!
…3905) # Objective - first part of bevyengine#13900 ## Solution - split `check_light_mesh_visibility `into `check_dir_light_mesh_visibility `and `check_point_light_mesh_visibility` for better review
Using struct expression and patterns is allowed in rust for tuple
structs. As per references. This allows us to simplify some of the
macros, and remove
underscores
from the utility module.