Skip to main content

PointConvert

Trait PointConvert 

Source
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§

Source

fn use_as<T>(&self) -> T
where T: From<Point>, Point: From<Self>, Self: Copy,

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 from Point.
§Constraints
  • T must implement From<Point>.
  • The canonical Point must implement From<Self>.
  • Self must be Copy.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<P> PointConvert for P
where P: Copy, Point: From<P>,