use_molecule/
atom_index.rs1use std::fmt;
2
3#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
5pub struct AtomIndex(usize);
6
7impl AtomIndex {
8 #[must_use]
10 pub const fn new(index: usize) -> Self {
11 Self(index)
12 }
13
14 #[must_use]
16 pub const fn get(self) -> usize {
17 self.0
18 }
19}
20
21impl From<usize> for AtomIndex {
22 fn from(value: usize) -> Self {
23 Self::new(value)
24 }
25}
26
27impl fmt::Display for AtomIndex {
28 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
29 write!(formatter, "{}", self.0)
30 }
31}
32
33#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
35pub struct AtomCount(usize);
36
37impl AtomCount {
38 #[must_use]
40 pub const fn new(count: usize) -> Self {
41 Self(count)
42 }
43
44 #[must_use]
46 pub const fn get(self) -> usize {
47 self.0
48 }
49
50 #[must_use]
52 pub const fn is_zero(self) -> bool {
53 self.0 == 0
54 }
55}
56
57impl From<usize> for AtomCount {
58 fn from(value: usize) -> Self {
59 Self::new(value)
60 }
61}
62
63impl fmt::Display for AtomCount {
64 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
65 write!(formatter, "{}", self.0)
66 }
67}