Open leftiness opened 7 years ago
Also implement a From conversion so I can do Point<T> = Borrow<Point<T>>.into()
instead of Point<T> = *Borrow<Point<T>>.borrow()
.
Then also change the generics of the functions to be like foo(T) where T: Into<Point>
. That'd get rid of the std::borrow::Borrow imports from most places.
Can't do. See #92 resolution.
Hm.
In #9, I'm going to impl<T, U> Travel<U> for T where T: Borrow<Point<U>>
, and I'll be able to do that because Travel will be a trait which is created in my crate. So I'll be able to do Borrow<Point<U>>.travel(Direction::East, 5)
.
Maybe I should create traits Add, Sub, etc. Then do something like impl<T, U> traits::Add<U, Output=U> for &T where &T: Borrow<U>, &U: ops::Add<&U, Output=U>
. Then you'll be able to do Borrow<Point<U>> + &Point<U>
if you have traits::Add in scope.
In that impl for traits::Add, just call the ops::Add function.
Look into it.
PS. Important to remember that this would be in a prelude, so you wouldn't really have to import traits::Add all the time if you didn't want to.
Gonna do this by itself. Not a prelude yet. I'll make another issue for that.
Make a trait in a prelude section. Library consumers will
use hex_math::prelude::*
. I'll do the same in lib.rs.In that trait,
impl <T, U> Add<T, Output = Point<U>> for T where T: Borrow<Point<U>>
. Those generics are probably not just right. Probably needs lifetimes at least.Anyway. Anybody who uses those prelude traits (or just the one prelude trait where this is implemented) should be able to do any of these:
Borrow<Point>
+ PointArc<Point<f32>>.t()
+&Prism.s() as f32
Move all of those functions out of point.rs. Maybe put each implementation in a different trait? Any value to that besides smaller files?