pub trait TryCastCoord<Src, Dst>where
    Src: NumCast,
    Dst: NumCast,{
    type Output;

    // Required method
    fn try_cast(&self) -> Option<Self::Output>;

    // Provided method
    fn cast(&self) -> Self::Output { ... }
}
Expand description

This trait defines the type-casting of the coordinate types for geometrical objects.

Required Associated Types§

type Output

Output type of the cast. This is likely the same geometrical type just with other coordinate types.

Required Methods§

fn try_cast(&self) -> Option<Self::Output>

Try to cast to target data type.

Conversion from float to int can fail and will return None. Float values like infinity or non-a-number have no integer representation.

Provided Methods§

fn cast(&self) -> Self::Output

Cast to target data type.

Conversion from float to int can fail and panic because float values like infinity or non-a-number have no integer representation.

Panics

Panics if casting of the coordinate values fails. For instance when trying to cast a ‘NaN’ float into a integer. Use try_cast to detect and handle this failure.

Implementors§

§

impl<T, Dst> TryCastCoord<T, Dst> for Geometry<T>where T: CoordinateType + NumCast, Dst: CoordinateType + NumCast,

§

type Output = Geometry<Dst>

§

impl<T, Dst> TryCastCoord<T, Dst> for Edge<T>where T: Copy + NumCast, Dst: Copy + NumCast,

§

type Output = Edge<Dst>

§

impl<T, Dst> TryCastCoord<T, Dst> for Path<T>where T: CoordinateType + NumCast, Dst: CoordinateType + NumCast,

§

type Output = Path<Dst>

§

impl<T, Dst> TryCastCoord<T, Dst> for Point<T>where T: Copy + NumCast, Dst: Copy + NumCast,

§

type Output = Point<Dst>

§

impl<T, Dst> TryCastCoord<T, Dst> for PointString<T>where T: Copy + NumCast, Dst: CoordinateType + NumCast,

§

type Output = PointString<Dst>

§

impl<T, Dst> TryCastCoord<T, Dst> for Polygon<T>where T: CoordinateType + NumCast, Dst: CoordinateType + NumCast,

§

type Output = Polygon<Dst>

§

impl<T, Dst> TryCastCoord<T, Dst> for REdge<T>where T: CoordinateType + NumCast, Dst: CoordinateType + NumCast,

§

type Output = REdge<Dst>

§

impl<T, Dst> TryCastCoord<T, Dst> for Rect<T>where T: CoordinateType + NumCast, Dst: CoordinateType + NumCast,

§

type Output = Rect<Dst>

§

impl<T, Dst> TryCastCoord<T, Dst> for SimplePolygon<T>where T: CoordinateType + NumCast, Dst: CoordinateType + NumCast,

§

impl<T, Dst> TryCastCoord<T, Dst> for SimpleRPolygon<T>where T: CoordinateType + NumCast, Dst: CoordinateType + NumCast,

§

impl<T, Dst> TryCastCoord<T, Dst> for SimpleTransform<T>where T: CoordinateType + NumCast, Dst: CoordinateType + NumCast,

§

impl<T, Dst> TryCastCoord<T, Dst> for Vector<T>where T: Copy + NumCast, Dst: Copy + NumCast,

§

type Output = Vector<Dst>

§

impl<T, Dst, S> TryCastCoord<T, Dst> for Text<T, S>where T: Copy + NumCast, Dst: Copy + NumCast, S: Clone,

§

type Output = Text<Dst, S>