# [−][src]Trait cgmath::Array

    pub trait Array where
        Self: Index<usize, Output = Self::Element>,
        Self: IndexMut<usize, Output = Self::Element>, {
        type Element: Copy;
        fn len() -> usize;
        fn from_value(value: Self::Element) -> Self;
        fn sum(self) -> Self::Element
        where
            Self::Element: Add<Output = Self::Element>;
        fn product(self) -> Self::Element
        where
            Self::Element: Mul<Output = Self::Element>;
        fn is_finite(&self) -> bool
        where
            Self::Element: BaseFloat;

        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) { ... }
    }

An array containing elements of type `Element`

## Associated Types

### `type Element: Copy`

Loading content...

## Required methods

### `fn len() -> usize`

Get the number of elements in the array type

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

    assert_eq!(Vector3::<f32>::len(), 3);

### `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));

### `fn sum(self) -> Self::Element where
Self::Element: Add<Output = Self::Element>,`

The sum of the elements of the array.

### `fn product(self) -> Self::Element where
Self::Element: Mul<Output = Self::Element>,`

The product of the elements of the array.

### `fn is_finite(&self) -> bool where
Self::Element: BaseFloat,`

Whether all elements of the array are finite

Loading content...

## Provided methods

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

Get the pointer to the first element of the array.

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

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

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

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

Loading content...

## Implementors

### `impl<S: BaseNum> Array for Point1<S>`[src]

#### `type Element = S`

#### `fn len() -> usize`[src]

#### `fn from_value(scalar: S) -> Point1<S>`[src]

#### `fn sum(self) -> S where
S: Add<Output = S>,` [src]

#### `fn product(self) -> S where
S: Mul<Output = S>,` [src]

#### `fn is_finite(&self) -> bool where
S: BaseFloat,` [src]

### `impl<S: BaseNum> Array for Point2<S>`[src]

#### `type Element = S`

#### `fn len() -> usize`[src]

#### `fn from_value(scalar: S) -> Point2<S>`[src]

#### `fn sum(self) -> S where
S: Add<Output = S>,` [src]

#### `fn product(self) -> S where
S: Mul<Output = S>,` [src]

#### `fn is_finite(&self) -> bool where
S: BaseFloat,` [src]

### `impl<S: BaseNum> Array for Point3<S>`[src]

#### `type Element = S`

#### `fn len() -> usize`[src]

#### `fn from_value(scalar: S) -> Point3<S>`[src]

#### `fn sum(self) -> S where
S: Add<Output = S>,` [src]

#### `fn product(self) -> S where
S: Mul<Output = S>,` [src]

#### `fn is_finite(&self) -> bool where
S: BaseFloat,` [src]

### `impl<S: Copy> Array for Vector1<S>`[src]

#### `type Element = S`

#### `fn len() -> usize`[src]

#### `fn from_value(scalar: S) -> Vector1<S>`[src]

#### `fn sum(self) -> S where
S: Add<Output = S>,` [src]

#### `fn product(self) -> S where
S: Mul<Output = S>,` [src]

#### `fn is_finite(&self) -> bool where
S: BaseFloat,` [src]

### `impl<S: Copy> Array for Vector2<S>`[src]

#### `type Element = S`

#### `fn len() -> usize`[src]

#### `fn from_value(scalar: S) -> Vector2<S>`[src]

#### `fn sum(self) -> S where
S: Add<Output = S>,` [src]

#### `fn product(self) -> S where
S: Mul<Output = S>,` [src]

#### `fn is_finite(&self) -> bool where
S: BaseFloat,` [src]

### `impl<S: Copy> Array for Vector3<S>`[src]

#### `type Element = S`

#### `fn len() -> usize`[src]

#### `fn from_value(scalar: S) -> Vector3<S>`[src]

#### `fn sum(self) -> S where
S: Add<Output = S>,` [src]

#### `fn product(self) -> S where
S: Mul<Output = S>,` [src]

#### `fn is_finite(&self) -> bool where
S: BaseFloat,` [src]

### `impl<S: Copy> Array for Vector4<S>`[src]

#### `type Element = S`

#### `fn len() -> usize`[src]

#### `fn from_value(scalar: S) -> Vector4<S>`[src]

#### `fn sum(self) -> S where
S: Add<Output = S>,` [src]

#### `fn product(self) -> S where
S: Mul<Output = S>,` [src]

#### `fn is_finite(&self) -> bool where
S: BaseFloat,` [src]

Loading content...

# Help

## Keyboard Shortcuts

`?`
  Show this help dialog
`S`
  Focus the search field
`↑`
  Move up in search results
`↓`
  Move down in search results
`↹`
  Switch tab
`⏎`
  Go to active search result
`+`
  Expand all sections
`-`
  Collapse all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g., `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g., `vec -> usize` or `* -> vec`)

Search multiple things at once by splitting your query with comma (e.g., `str,u8` or `String,struct:Vec,test`)