1#![forbid(unsafe_code)]
2#![doc = include_str!("../README.md")]
3
4#[derive(Debug, Clone, Copy, PartialEq, Eq)]
6pub struct Cell {
7 dimension: usize,
8 boundary_count: usize,
9}
10
11impl Cell {
12 #[must_use]
14 pub const fn new(dimension: usize, boundary_count: usize) -> Option<Self> {
15 if dimension > 0 {
16 Some(Self {
17 dimension,
18 boundary_count,
19 })
20 } else {
21 None
22 }
23 }
24
25 #[must_use]
27 pub const fn dimension(self) -> usize {
28 self.dimension
29 }
30
31 #[must_use]
33 pub const fn boundary_count(self) -> usize {
34 self.boundary_count
35 }
36}
37
38#[cfg(test)]
39mod tests {
40 use super::Cell;
41
42 #[test]
43 fn stores_cell_metadata() {
44 let cell = Cell::new(2, 4).expect("valid cell");
45
46 assert_eq!(cell.dimension(), 2);
47 assert_eq!(cell.boundary_count(), 4);
48 assert_eq!(Cell::new(0, 1), None);
49 }
50}