1#![forbid(unsafe_code)]
2#![doc = include_str!("../README.md")]
3
4#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
6pub struct ManifoldDimension(usize);
7
8impl ManifoldDimension {
9 #[must_use]
11 pub const fn new(value: usize) -> Option<Self> {
12 Some(Self(value))
13 }
14
15 #[must_use]
17 pub const fn value(self) -> usize {
18 self.0
19 }
20}
21
22#[derive(Debug, Clone, Copy, PartialEq, Eq)]
24pub enum BoundaryKind {
25 WithoutBoundary,
27 WithBoundary,
29 Unspecified,
31}
32
33#[derive(Debug, Clone, Copy, PartialEq, Eq)]
35pub struct Manifold {
36 dimension: ManifoldDimension,
37 boundary_kind: BoundaryKind,
38}
39
40impl Manifold {
41 #[must_use]
43 pub const fn new(dimension: ManifoldDimension, boundary_kind: BoundaryKind) -> Self {
44 Self {
45 dimension,
46 boundary_kind,
47 }
48 }
49
50 #[must_use]
52 pub const fn dimension(self) -> ManifoldDimension {
53 self.dimension
54 }
55
56 #[must_use]
58 pub const fn boundary_kind(self) -> BoundaryKind {
59 self.boundary_kind
60 }
61}
62
63#[cfg(test)]
64mod tests {
65 use super::{BoundaryKind, Manifold, ManifoldDimension};
66
67 #[test]
68 fn stores_manifold_metadata() {
69 let dimension = ManifoldDimension::new(2).expect("valid dimension");
70 let manifold = Manifold::new(dimension, BoundaryKind::WithoutBoundary);
71
72 assert_eq!(dimension.value(), 2);
73 assert_eq!(manifold.dimension(), dimension);
74 assert_eq!(manifold.boundary_kind(), BoundaryKind::WithoutBoundary);
75 }
76}