Trait Get

pub trait Get<Index> {
    type Component;

    // Required methods
    fn get_ref(&self, index: Index) -> &Self::Component;
    fn get_mut(&mut self, index: Index) -> &mut Self::Component;

    // Provided methods
    fn get(self, index: Index) -> Self::Component
       where Self: Sized,
             Self::Component: Copy { ... }
    fn set(&mut self, index: Index, component: Self::Component) { ... }
    fn with(self, index: Index, component: Self::Component) -> Self
       where Self: Sized { ... }
}
Expand description

Generic access to a structure’s components.

Required Associated Types§

type Component

The structure’s component type.

Required Methods§

fn get_ref(&self, index: Index) -> &Self::Component

Borrow the component for the specified index.

fn get_mut(&mut self, index: Index) -> &mut Self::Component

Borrow the component for the specified index mutably.

Provided Methods§

fn get(self, index: Index) -> Self::Component
where Self: Sized, Self::Component: Copy,

Convenience method for getting a copy of a component.

fn set(&mut self, index: Index, component: Self::Component)

Convenience method for setting a component.

fn with(self, index: Index, component: Self::Component) -> Self
where Self: Sized,

Builder-style method for setting a component.

Implementations on Foreign Types§

§

impl Get<Axis> for Point

§

type Component = Abs

§

fn get_ref(&self, axis: Axis) -> &Abs

§

fn get_mut(&mut self, axis: Axis) -> &mut Abs

§

impl<T> Get<Axis> for Axes<T>

§

type Component = T

§

fn get_ref(&self, axis: Axis) -> &T

§

fn get_mut(&mut self, axis: Axis) -> &mut T

§

impl<T> Get<Corner> for Corners<T>

§

type Component = T

§

fn get_ref(&self, corner: Corner) -> &T

§

fn get_mut(&mut self, corner: Corner) -> &mut T

§

impl<T> Get<Side> for Sides<T>

§

type Component = T

§

fn get_ref(&self, side: Side) -> &T

§

fn get_mut(&mut self, side: Side) -> &mut T

Implementors§