pub trait PointConvert {
// Required method
fn use_as<T>(&self) -> T
where T: From<Point>,
Point: From<Self>,
Self: Copy;
}Expand description
A trait for generically converting between different point types.
Any type that implements Copy and has From implementations to and from
the canonical Point struct will automatically implement this trait.
It provides a use_as method to convert an instance of a point type into another
point type, using Point as the intermediary.
Required Methods§
Sourcefn use_as<T>(&self) -> T
fn use_as<T>(&self) -> T
Converts the point into a different point type T.
This method leverages the canonical Point struct as a bridge. The conversion
follows the path: Self -> Point -> T.
§Type Parameters
T: The target point type. It must be convertible fromPoint.
§Constraints
Tmust implementFrom<Point>.- The canonical
Pointmust implementFrom<Self>. Selfmust beCopy.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".