We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 118ed20 commit 294f6beCopy full SHA for 294f6be
src/map.rs
@@ -10,6 +10,9 @@ use crate::points::Point2D;
10
pub struct Map2D<T>(Vec<Vec<T>>);
11
12
impl<T> Map2D<T> {
13
+ pub fn new(v: Vec<Vec<T>>) -> Self {
14
+ Self(v)
15
+ }
16
pub fn height(&self) -> usize {
17
self.0.len()
18
}
@@ -41,6 +44,18 @@ where
41
44
42
45
43
46
47
+/// ```rust
48
+/// # use libaoc::{map::Map2D, points::Point2D};
49
+/// let v = vec![
50
+/// vec![1, 2, 3],
51
+/// vec![4, 5, 6],
52
+/// vec![7, 8, 9]
53
+/// ];
54
+/// let m = Map2D::new(v);
55
+/// let pos: Point2D<usize> = Point2D(1, 2);
56
+///
57
+/// assert_eq!(m[pos], 8);
58
+/// ```
59
impl<T, U> Index<Point2D<T>> for Map2D<U>
60
where
61
T: Into<usize>,
0 commit comments