Use field access syntax in enum macros#1
Merged
MrGVSV merged 3 commits intoMrGVSV:reflect-enumfrom Jun 27, 2022
Merged
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
MrGVSV
requested changes
Jun 25, 2022
Owner
MrGVSV
left a comment
There was a problem hiding this comment.
Definitely much cleaner. Left a few suggestions (feel free to dispute them if you feel strongly about them, though).
Author
|
Nice suggestions! I'll update this tomorrow. |
Author
|
Applied all your suggestions |
nicopap
commented
Jun 26, 2022
MrGVSV
reviewed
Jun 26, 2022
d4df183 to
9f10360
Compare
MrGVSV
approved these changes
Jun 27, 2022
Comment on lines
+32
to
+50
| /// 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. |
MrGVSV
pushed a commit
that referenced
this pull request
Jun 26, 2024
…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
MrGVSV
pushed a commit
that referenced
this pull request
Feb 28, 2025
…res. (bevyengine#17887) Fixes bevyengine#17290. <details> <summary>Compilation errors before fix</summary> `cargo clippy --tests --all-features --package bevy_image`: ```rust error[E0061]: this function takes 7 arguments but 6 arguments were supplied --> crates/bevy_core_pipeline/src/tonemapping/mod.rs:451:5 | 451 | Image::from_buffer( | ^^^^^^^^^^^^^^^^^^ ... 454 | bytes, | ----- argument #1 of type `std::string::String` is missing | note: associated function defined here --> /Users/josiahnelson/Desktop/Programming/Rust/bevy/crates/bevy_image/src/image.rs:930:12 | 930 | pub fn from_buffer( | ^^^^^^^^^^^ help: provide the argument | 451 | Image::from_buffer(/* std::string::String */, bytes, image_type, CompressedImageFormats::NONE, false, image_sampler, RenderAssetUsages::RENDER_WORLD) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``` `cargo clippy --tests --all-features --package bevy_gltf`: ```rust error[E0560]: struct `bevy_pbr::StandardMaterial` has no field named `specular_channel` --> crates/bevy_gltf/src/loader.rs:1343:13 | 1343 | specular_channel: specular.specular_channel, | ^^^^^^^^^^^^^^^^ `bevy_pbr::StandardMaterial` does not have this field | = note: available fields are: `emissive_exposure_weight`, `diffuse_transmission`, `diffuse_transmission_channel`, `diffuse_transmission_texture`, `flip_normal_map_y` ... and 9 others error[E0560]: struct `bevy_pbr::StandardMaterial` has no field named `specular_texture` --> crates/bevy_gltf/src/loader.rs:1345:13 | 1345 | specular_texture: specular.specular_texture, | ^^^^^^^^^^^^^^^^ `bevy_pbr::StandardMaterial` does not have this field | = note: available fields are: `emissive_exposure_weight`, `diffuse_transmission`, `diffuse_transmission_channel`, `diffuse_transmission_texture`, `flip_normal_map_y` ... and 9 others error[E0560]: struct `bevy_pbr::StandardMaterial` has no field named `specular_tint_channel` --> crates/bevy_gltf/src/loader.rs:1351:13 | 1351 | specular_tint_channel: specular.specular_color_channel, | ^^^^^^^^^^^^^^^^^^^^^ `bevy_pbr::StandardMaterial` does not have this field | = note: available fields are: `emissive_exposure_weight`, `diffuse_transmission`, `diffuse_transmission_channel`, `diffuse_transmission_texture`, `flip_normal_map_y` ... and 9 others error[E0560]: struct `bevy_pbr::StandardMaterial` has no field named `specular_tint_texture` --> crates/bevy_gltf/src/loader.rs:1353:13 | 1353 | specular_tint_texture: specular.specular_color_texture, | ^^^^^^^^^^^^^^^^^^^^^ `bevy_pbr::StandardMaterial` does not have this field | = note: available fields are: `emissive_exposure_weight`, `diffuse_transmission`, `diffuse_transmission_channel`, `diffuse_transmission_texture`, `flip_normal_map_y` ... and 9 others ``` </details>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
underscoresfrom the utility module.