rust/vec2d/src/lib.rs
changeset 13935 5c9d963492bf
parent 13929 a140f28decc4
child 14035 2ebd505e62c1
--- a/rust/vec2d/src/lib.rs	Tue Oct 16 23:49:44 2018 +0300
+++ b/rust/vec2d/src/lib.rs	Tue Oct 16 23:59:22 2018 +0200
@@ -51,13 +51,23 @@
     }
 
     #[inline]
+    pub fn get(&self, row: usize, column: usize) -> Option<&<usize as SliceIndex<[T]>>::Output> {
+        self.data.get(row * self.width + column)
+    }
+
+    #[inline]
     pub fn get_mut(&mut self, row: usize, column: usize) -> Option<&mut <usize as SliceIndex<[T]>>::Output> {
         self.data.get_mut(row * self.width + column)
     }
 
     #[inline]
-    pub fn get(&self, row: usize, column: usize) -> Option<&<usize as SliceIndex<[T]>>::Output> {
-        self.data.get(row * self.width + column)
+    pub unsafe fn get_unchecked(&self, row: usize, column: usize) -> &<usize as SliceIndex<[T]>>::Output {
+        self.data.get_unchecked(row * self.width + column)
+    }
+
+    #[inline]
+    pub unsafe fn get_unchecked_mut(&mut self, row: usize, column: usize) -> &mut <usize as SliceIndex<[T]>>::Output {
+        self.data.get_unchecked_mut(row * self.width + column)
     }
 }