Support converting arrays of integers to Rect via TryFrom#1403
Support converting arrays of integers to Rect via TryFrom#1403lolbinarycat wants to merge 3 commits intoRust-SDL2:masterfrom
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.