# Module cgmath::conv [−] [src]

Constrained conversion functions for assisting in situations where type inference is difficult.

For example, when declaring `glium` uniforms, we need to convert to fixed length arrays. We can use the `Into` trait directly, but it is rather ugly!

```#[macro_use]
extern crate glium;
extern crate cgmath;

use cgmath::{Matrix4, Point2};
use cgmath::prelude::*;

let point = Point2::new(1, 2);
let matrix = Matrix4::from_scale(2.0);

let uniforms = uniform! {
point: Into::<[_; 2]>::into(point),
matrix: Into::<[[_; 4]; 4]>::into(matrix),
// Yuck!! (ﾉಥ益ಥ）ﾉ﻿ ┻━┻
};```

Instead, we can use the conversion functions from the `conv` module:

```#[macro_use]
extern crate glium;
extern crate cgmath;

use cgmath::{Matrix4, Point2};
use cgmath::prelude::*;
use cgmath::conv::*;

let point = Point2::new(1, 2);
let matrix = Matrix4::from_scale(2.0);

let uniforms = uniform! {
point: array2(point),
matrix: array4x4(matrix),
// ┬─┬ノ( º _ ºノ)
};```

## Functions

 array2 Force a conversion into a 2-element array. array2x2 Force a conversion into a 2x2-element array. array3 Force a conversion into a 3-element array. array3x3 Force a conversion into a 3x3-element array. array4 Force a conversion into a 4-element array. array4x4 Force a conversion into a 4x4-element array.