kvark / mint

Math Interoperability Types
MIT License
252 stars 20 forks source link

Easy component type conversion, between mint types #40

Open lo48576 opened 5 years ago

lo48576 commented 5 years ago

I think people (including me) sometimes want to convert f64 types and f32 types or such component type conversion. For example, downgrading Point3<f64> to Point3<f32>.

These conversions cannot be written using only From and Into trait (because of coherence), so usually it is done by .map() function. (See Option::map and Result::map for example.)

I'm not sure how this should be implemented in this crate, .map() method, Map trait, or something else...

Are these component type conversion in scope of this crate?

lo48576 commented 5 years ago

FYI: rgb crate has ComponentMap trait to do that.

kvark commented 5 years ago

It sounds fairly straightforward: the feature is generic, doesn't involve any math specifically, and can be implemented with just a few blocks. I think we could have it in scope. As for ComponentMap, it's a pretty solution but it doesn't appear to be providing a lot of benefit to mint since our types don't have any methods that would be confusingly conflict with map.