georust / proj

Rust bindings for the latest stable release of PROJ
https://docs.rs/proj
Apache License 2.0
143 stars 46 forks source link

`.convert` does not need to bind input type with output type #84

Open woshilapin opened 3 years ago

woshilapin commented 3 years ago

the .convert() function needs an input type with a bound constraint on Coord<T> and produce an output type with a bound constraint on Coord<T>. However, the way it is defined today forces the 2 concrete types to be the same.

pub fn convert<C, F>(&self, point: C) -> Result<C, ProjError>
where
    C: Coord<F>,
    F: CoordinateType;

But it doesn't have to be like this. We could define the function as follows.

pub fn convert<C, D, F>(&self, point: C) -> Result<D, ProjError>
where
    C: Coord<F>,
    D: Coord<F>,
    F: CoordinateType;

Note however that this would be a breaking change for the crate proj as now, the expected type should be made explicit and type inference might not always be able to save you.