Skip to content

Assorted cleanliness refactors #16250

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

sharma-shray
Copy link

@sharma-shray sharma-shray commented Nov 5, 2024

Small refactor for some assorted code quality issues.

@alice-i-cecile alice-i-cecile added C-Code-Quality A section of code that is hard to understand or change A-Reflection Runtime information about types labels Nov 5, 2024
@alice-i-cecile alice-i-cecile changed the title some refactoring Refactor some bevy_reflect macros for cleanliness Nov 5, 2024
@alice-i-cecile alice-i-cecile requested a review from MrGVSV November 5, 2024 19:34
@alice-i-cecile alice-i-cecile added the S-Needs-Review Needs reviewer attention (from anyone!) to move forward label Nov 5, 2024
@alice-i-cecile
Copy link
Member

Please try to include a basic PR description and title: it makes this sort of thing much easier to review.

@alice-i-cecile alice-i-cecile added D-Macros Code that generates Rust code D-Straightforward Simple bug fixes and API improvements, docs, test and examples D-Domain-Agnostic Can be tackled by anyone with generic programming or Rust skills labels Nov 5, 2024
Copy link
Member

@MrGVSV MrGVSV left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good, but this seems to touch more than just bevy_reflect. That should probably be mentioned in the title/description as well.

@alice-i-cecile alice-i-cecile changed the title Refactor some bevy_reflect macros for cleanliness Refactor some macros for cleanliness Nov 5, 2024
@alice-i-cecile alice-i-cecile added A-UI Graphical user interfaces, styles, layouts, and widgets A-States App-level states machines labels Nov 5, 2024
@alice-i-cecile alice-i-cecile changed the title Refactor some macros for cleanliness Assorted cleanliness refactors Nov 5, 2024
@alice-i-cecile
Copy link
Member

Merging. Please split these out and have a proper description next time though.

@@ -95,8 +95,7 @@ impl RelativeCursorPosition {
/// A helper function to check if the mouse is over the node
pub fn mouse_over(&self) -> bool {
self.normalized
.map(|position| self.normalized_visible_node_rect.contains(position))
.unwrap_or(false)
.map_or(false, |position| self.normalized_visible_node_rect.contains(position))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as in #16205, there's some distaste amongst some contributors (me included) with using map_or as it's harder to read because it put the "or" case first

Copy link
Contributor

@ickshonpe ickshonpe Nov 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, hate it.

If map_or is used in the middle of a chain of composed functions then I can see it might be okay (maybe?). Placed at the end of a chain thouigh I very strongly prefer unwrap_or.

Comment on lines +18 to +20
fn custom_default() -> i32 {
-1
}
Copy link
Member

@mockersf mockersf Nov 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to keep this where it was, duplicated in both tests. this function doesn't really make sense as a "global" function, and it reduces readability by making it far away from where it's used

@mockersf mockersf disabled auto-merge November 5, 2024 23:37
Copy link
Member

@mockersf mockersf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't pass CI and should be fixed first

and please don't open duplicate PRs but update the one you already have, and use the description and title of the PR to provide meaningful information

@alice-i-cecile alice-i-cecile added S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Nov 6, 2024
}
}
name.map(String::into_boxed_str)
name
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ickshonpe is this still relevant? https://github.com/bevyengine/bevy/pull/16205/files#r1829513146
I don't see the issue. 🤔

@doup
Copy link
Contributor

doup commented Nov 6, 2024

Looks like #16205 should be closed in favor of this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Reflection Runtime information about types A-States App-level states machines A-UI Graphical user interfaces, styles, layouts, and widgets C-Code-Quality A section of code that is hard to understand or change D-Domain-Agnostic Can be tackled by anyone with generic programming or Rust skills D-Macros Code that generates Rust code D-Straightforward Simple bug fixes and API improvements, docs, test and examples S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants