cgmath icon indicating copy to clipboard operation
cgmath copied to clipboard

num::cast(5.0).unwrap() is ugly

Open brendanzab opened this issue 8 years ago • 1 comments

As mentioned in #319, num::cast(5.0).unwrap() is an ugly way for clients to construct generic literals. It might be worth exploring if cgmath can expose something nicer to authors of generic libraries.

brendanzab avatar Apr 11 '16 23:04 brendanzab

So it seems like all floats support From<f32>. This would allow for things like S::from(1.0).

Unfortunately the integer situation is more complex. All integers From<i8>. All unsigned integers From<u8>. But coming up with a nice common conversion is hard, which makes it difficult to support parameterising by unsigned integers :(

brendanzab avatar Apr 24 '16 02:04 brendanzab