summaryrefslogtreecommitdiffstats
path: root/CLI/rust/src/game_of_life/simulation/plane.rs
diff options
context:
space:
mode:
Diffstat (limited to 'CLI/rust/src/game_of_life/simulation/plane.rs')
-rw-r--r--CLI/rust/src/game_of_life/simulation/plane.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/CLI/rust/src/game_of_life/simulation/plane.rs b/CLI/rust/src/game_of_life/simulation/plane.rs
index 21c34cf..11d7ee5 100644
--- a/CLI/rust/src/game_of_life/simulation/plane.rs
+++ b/CLI/rust/src/game_of_life/simulation/plane.rs
@@ -8,6 +8,24 @@ use std::ops::{Index, IndexMut};
#[derive(Debug, Clone, PartialEq)]
pub(crate) struct Plane<T>(pub Vec<T>);
+impl<T> Plane<T> {
+ pub fn len(&self) -> isize {
+ self.0.len() as isize
+ }
+}
+
+#[cfg(test)]
+mod len {
+ use super::*;
+
+ #[test]
+ fn get_len() {
+ assert_eq!(Plane(vec![false, false, true, false, false]).len(), 5);
+ assert_eq!(Plane(vec![false, false, true, false]).len(), 4);
+ assert_eq!(Plane(vec![false, false, true]).len(), 3);
+ }
+}
+
impl<T> Index<isize> for Plane<T> {
type Output = T;
fn index(&self, idx: isize) -> &T {