-
Notifications
You must be signed in to change notification settings - Fork 474
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
Support converting arrays of integers to Rect via TryFrom #1403
base: master
Are you sure you want to change the base?
Conversation
Done as a seperate commit since it needs to reference the PR number.
Something tells me this will fail fmt |
Done as a seperate commit since it needs to reference the PR number.
d3e38c5
to
bd1b825
Compare
You should put the doc comments on Accepting all types that are Also, using an array does not make sense to me because a Rect is not some sort of list, each value has a distinct meaning (namely x, y, width and height). |
do you have a better idea? i don't think rust provides a generic way to do a clamping type conversion.
yet it still supports casts from tuples, which are basically just heterogeneous lists. |
The standard library does not provide this, but you can make a custom trait to do saturating conversion to i32 and u32. (To me this does seem overkill for one conversion function.)
A tuple gets closer to Rect than an array (type per field), but fields are still unnamed. |
I do agree that tuples are better, but maybe there is a specific usecase like matrix computing or something. @lolbinarycat why do you need this specifically? |
No description provided.