ultraviolet icon indicating copy to clipboard operation
ultraviolet copied to clipboard

Tracking: `num-traits` support

Open virtualritz opened this issue 1 year ago • 6 comments

A user of my uniform-cubic-splines crate wanted to use it with ultraviolet and ran into a traits issue.

My crate relies on Zero/One traits. Those were removed from std::num (unfortunately, I think), in 2014. My crate uses num-traits::Zero/One.

That means if some third party crate that implements a type that someone wants to use with my crate does not implement the num-traits version of these traits, it won't work. A user can't add support for it on their side (and neither can even my crate) because of orphan rules.

I guess the only solution would be to add support for this to ultraviolet. FYI, cgmath, glam & nalgebra all support these.

Would you consider this at all (or a PR)?

virtualritz avatar Mar 20 '23 09:03 virtualritz

Yeah absolutely. Can just make it an optional dependency and put the implementation under that feature flag :)

Only reason it hasn't been done already is I haven't needed it and nobody else has implemented it :P

fu5ha avatar Mar 20 '23 09:03 fu5ha

Okidoki. I'll look into it soon.

virtualritz avatar Mar 20 '23 11:03 virtualritz

Would you like the trait impls to live in their own file, e.g. src/vec/traits.rs or in each existing src/vec/vec?.rs file resp.?

virtualritz avatar Mar 20 '23 11:03 virtualritz

I think separate file is probably best

fu5ha avatar Mar 20 '23 11:03 fu5ha

Shall we keep this open to track further num-traits trait impls?

virtualritz avatar Mar 20 '23 15:03 virtualritz

Sure :)

fu5ha avatar Mar 20 '23 15:03 fu5ha