1use std::fmt;
2
3use use_chemical_formula::ChemicalFormula;
4use use_stoichiometry::StoichiometricCoefficient;
5
6use crate::ReactionTerm;
7
8#[derive(Clone, Debug, Eq, PartialEq)]
10pub struct Product(ReactionTerm);
11
12impl Product {
13 #[must_use]
15 pub const fn new(term: ReactionTerm) -> Self {
16 Self(term)
17 }
18
19 #[must_use]
21 pub const fn as_term(&self) -> &ReactionTerm {
22 &self.0
23 }
24
25 #[must_use]
27 pub fn into_term(self) -> ReactionTerm {
28 self.0
29 }
30
31 #[must_use]
33 pub const fn coefficient(&self) -> StoichiometricCoefficient {
34 self.0.coefficient()
35 }
36
37 #[must_use]
39 pub const fn formula(&self) -> &ChemicalFormula {
40 self.0.formula()
41 }
42}
43
44impl From<ReactionTerm> for Product {
45 fn from(term: ReactionTerm) -> Self {
46 Self::new(term)
47 }
48}
49
50impl fmt::Display for Product {
51 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
52 write!(formatter, "{}", self.0)
53 }
54}