logo
pub trait AsPositionMut: AsPosition {
    fn as_position_mut(&mut self) -> &mut Self::Position;

    fn transform<F>(&mut self, f: F)
    where
        F: FnMut(&Self::Position) -> Self::Position
, { ... } fn map_position<F>(self, f: F) -> Self
    where
        F: FnMut(&Self::Position) -> Self::Position
, { ... } }
Expand description

Mutable positional data.

This trait exposes positional data for geometric types along with its immutable variant AsPosition.

Examples

Exposing mutable positional data for a vertex:

use nalgebra::{Point3, Vector3};
use theon::{AsPosition, AsPositionMut};

pub struct Vertex {
    position: Point3<f64>,
    normal: Vector3<f64>,
}

impl AsPosition for Vertex {
    type Position = Point3<f64>;

    fn as_position(&self) -> &Self::Position {
        &self.position
    }
}

impl AsPositionMut for Vertex {
    fn as_position_mut(&mut self) -> &mut Self::Position {
        &mut self.position
    }
}

Required Methods

Provided Methods

Implementations on Foreign Types

Implementors