rust/vec2d/src/lib.rs
changeset 13935 5c9d963492bf
parent 13929 a140f28decc4
child 14035 2ebd505e62c1
equal deleted inserted replaced
13934:ff77c9920007 13935:5c9d963492bf
    49     pub fn height(&self) -> usize {
    49     pub fn height(&self) -> usize {
    50         self.height
    50         self.height
    51     }
    51     }
    52 
    52 
    53     #[inline]
    53     #[inline]
       
    54     pub fn get(&self, row: usize, column: usize) -> Option<&<usize as SliceIndex<[T]>>::Output> {
       
    55         self.data.get(row * self.width + column)
       
    56     }
       
    57 
       
    58     #[inline]
    54     pub fn get_mut(&mut self, row: usize, column: usize) -> Option<&mut <usize as SliceIndex<[T]>>::Output> {
    59     pub fn get_mut(&mut self, row: usize, column: usize) -> Option<&mut <usize as SliceIndex<[T]>>::Output> {
    55         self.data.get_mut(row * self.width + column)
    60         self.data.get_mut(row * self.width + column)
    56     }
    61     }
    57 
    62 
    58     #[inline]
    63     #[inline]
    59     pub fn get(&self, row: usize, column: usize) -> Option<&<usize as SliceIndex<[T]>>::Output> {
    64     pub unsafe fn get_unchecked(&self, row: usize, column: usize) -> &<usize as SliceIndex<[T]>>::Output {
    60         self.data.get(row * self.width + column)
    65         self.data.get_unchecked(row * self.width + column)
       
    66     }
       
    67 
       
    68     #[inline]
       
    69     pub unsafe fn get_unchecked_mut(&mut self, row: usize, column: usize) -> &mut <usize as SliceIndex<[T]>>::Output {
       
    70         self.data.get_unchecked_mut(row * self.width + column)
    61     }
    71     }
    62 }
    72 }
    63 
    73 
    64 #[cfg(test)]
    74 #[cfg(test)]
    65 mod tests {
    75 mod tests {