-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Add a new trait to accept more types in the Val
-helper functions
#20551
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 a new trait to accept more types in the Val
-helper functions
#20551
Conversation
This is still waiting for a decision on #20549. And this should probably be mentioned with the helper functions in the release notes. If so, I'll have to look into that. |
This also needs testing against #20158, to ensure that it plays nice with BSN. |
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 don't understand why we need a dedicated ToValNum
trait. Why can't we just use impl Into<Val>
?
You mean: impl From<i32> for Val {
fn from(value: i32) {
Val::Px(value as f32)
}
} That would have the issues with having to specify a default unit, see #20517 and @cart's comment: #20517 (comment) Or am I missing something? |
Ah, I see. Can you please explain this in a doc comment on |
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.
LGTM if we can get this working with BSN.
Ok, so I just switched to that branch and merged these changes locally and experimented with the examples. There don't seem to be any problems. I'll update the examples in here tomorrow and will do the same for BSN once cart merges main into the feature branch again. |
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 don't like the extra conversions or the macro, it just seems useless to me.
The use case for this is just we want to be able to type px(10)
instead of px(10.)
, which only needs i32
. The times you'd need the other conversions are so rare, I don't see any problem with requiring an explicit cast. It could even hide errors, using i128/u128
s for UI coords seems especially fishy.
Practically its not going to make any significant difference though, so I approve anyway with that objection.
The argument could be made to remove Thanks for the feedback |
Sorry for the big commit. I changed all the references to |
Objective
Val
-helper functions to accept more types besides justf32
Fixes #20549
Solution
self
tof32
Testing
Rust test
Showcase