Skip to content

Commit 8ca2636

Browse files
committed
somem more doc
1 parent 99d838f commit 8ca2636

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

src/lib.rs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ where
158158
impl<C, const ROWS: usize, const COLS: usize, const Q: usize> Mul<Matrix<C, Q, COLS>>
159159
for Matrix<C, ROWS, Q>
160160
where
161-
//clone may be more appropriate here, is there a way not to require neither Copy nor Clone?
161+
//clone may be more appropriate here, is there a way to require neither Copy nor Clone?
162162
C: Add + Mul<C, Output = C> + Sum + Clone,
163163
{
164164
type Output = Matrix<C, ROWS, COLS>;
@@ -188,7 +188,16 @@ impl<C, const SIZE: usize> Matrix<C, SIZE, SIZE>
188188
where
189189
C: One + Zero + Copy,
190190
{
191-
///Returns the identity matrix of size `SIZE`
191+
///Returns the identity matrix of size `SIZE`.
192+
/// Note that this often requires type annotation.
193+
///
194+
/// # Example
195+
///
196+
/// ```
197+
///# use matrix::Matrix;
198+
/// let identity: Matrix<u8, 2, 2> = Matrix::identity();
199+
/// assert_eq!(identity, [[1, 0], [0, 1]].into());
200+
/// ```
192201
pub fn identity() -> Self {
193202
let mut m = Self::nil();
194203
for i in 0..SIZE {
@@ -197,7 +206,16 @@ where
197206
m
198207
}
199208

200-
///Returns the nil matrix of size `SIZE`
209+
///Returns the nil matrix of size `SIZE`.
210+
/// Note that this often requires type annotation.
211+
///
212+
/// # Example
213+
///
214+
/// ```
215+
///# use matrix::Matrix;
216+
/// let identity: Matrix<u8, 2, 2> = Matrix::nil();
217+
/// assert_eq!(identity, [[0, 0], [0, 0]].into());
218+
/// ```
201219
pub fn nil() -> Self {
202220
[[C::zero(); SIZE]; SIZE].into()
203221
}

tests/op_tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ mod matrix_setup {
44
use matrix::Matrix;
55
use rand::{thread_rng, Rng};
66

7+
#[allow(unused)]
78
pub fn setup_rand_3x2() -> Matrix<u8, 3, 2> {
89
let mut m = [[0; 2]; 3];
910
let mut rng = thread_rng();

0 commit comments

Comments
 (0)