Trait cgmath::prelude::Array

source ·
pub trait Arraywhere
    Self: Index<usize, Output = Self::Element> + IndexMut<usize, Output = Self::Element>,{
    type Element: Copy;

    // Required methods
    fn from_value(value: Self::Element) -> Self;
    fn sum(self) -> Self::Element
       where Self::Element: Add<Output = <Self as Array>::Element>;
    fn product(self) -> Self::Element
       where Self::Element: Mul<Output = <Self as Array>::Element>;
    fn min(self) -> Self::Element
       where Self::Element: PartialOrd;
    fn max(self) -> Self::Element
       where Self::Element: PartialOrd;

    // Provided methods
    fn as_ptr(&self) -> *const Self::Element { ... }
    fn as_mut_ptr(&mut self) -> *mut Self::Element { ... }
    fn swap_elements(&mut self, i: usize, j: usize) { ... }
}
Expand description

An array containing elements of type Element

Required Associated Types§

Required Methods§

source

fn from_value(value: Self::Element) -> Self

Construct a vector from a single value, replicating it.

use cgmath::prelude::*;
use cgmath::Vector3;

assert_eq!(Vector3::from_value(1),
           Vector3::new(1, 1, 1));
source

fn sum(self) -> Self::Elementwhere Self::Element: Add<Output = <Self as Array>::Element>,

The sum of the elements of the array.

source

fn product(self) -> Self::Elementwhere Self::Element: Mul<Output = <Self as Array>::Element>,

The product of the elements of the array.

source

fn min(self) -> Self::Elementwhere Self::Element: PartialOrd,

The minimum element of the array.

source

fn max(self) -> Self::Elementwhere Self::Element: PartialOrd,

The maximum element of the array.

Provided Methods§

source

fn as_ptr(&self) -> *const Self::Element

Get the pointer to the first element of the array.

source

fn as_mut_ptr(&mut self) -> *mut Self::Element

Get a mutable pointer to the first element of the array.

source

fn swap_elements(&mut self, i: usize, j: usize)

Swap the elements at indices i and j in-place.

Implementors§

source§

impl<S: BaseNum> Array for Point1<S>

§

type Element = S

source§

impl<S: BaseNum> Array for Point2<S>

§

type Element = S

source§

impl<S: BaseNum> Array for Point3<S>

§

type Element = S

source§

impl<S: Copy> Array for Vector1<S>

§

type Element = S

source§

impl<S: Copy> Array for Vector2<S>

§

type Element = S

source§

impl<S: Copy> Array for Vector3<S>

§

type Element = S

source§

impl<S: Copy> Array for Vector4<S>

§

type Element = S