-
Notifications
You must be signed in to change notification settings - Fork 126
Open
Description
Related to #231, but I think it's complementary.
Right now, the generated Unit trait makes it difficult to write methods that work generically over different types of Units. For example:
fn do_work<N>(value: f64) -> Quantity<D, U, f64>
where N: Unit
{
Quantity::new::<N>(value) // Error! Cannot infer type of D and U
}
It would be great if some associated types could be added to the Unit trait:
pub trait Unit: Copy {
/// The dimension of this unit.
type Dimension: Dimension;
/// The base units of this unit.
type Units: Units;
...
}
So that we can write:
fn do_work<N>(value: f64) -> Quantity<D, U, f64>
where N: Unit
{
Quantity::<N::Dimension, N::Units, _>::new::<N>(value)
}
Metadata
Metadata
Assignees
Labels
No labels