#![forbid(unsafe_code)]
#![doc = include_str!("../README.md")]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Cell {
dimension: usize,
boundary_count: usize,
}
impl Cell {
#[must_use]
pub const fn new(dimension: usize, boundary_count: usize) -> Option<Self> {
if dimension > 0 {
Some(Self {
dimension,
boundary_count,
})
} else {
None
}
}
#[must_use]
pub const fn dimension(self) -> usize {
self.dimension
}
#[must_use]
pub const fn boundary_count(self) -> usize {
self.boundary_count
}
}
#[cfg(test)]
mod tests {
use super::Cell;
#[test]
fn stores_cell_metadata() {
let cell = Cell::new(2, 4).expect("valid cell");
assert_eq!(cell.dimension(), 2);
assert_eq!(cell.boundary_count(), 4);
assert_eq!(Cell::new(0, 1), None);
}
}