Struct ChemicalFormula
pub struct ChemicalFormula { /* private fields */ }Expand description
A chemical formula with a main part and optional hydrate parts.
Implementations§
§impl ChemicalFormula
impl ChemicalFormula
pub fn new(
main_part: FormulaPart,
hydrate_parts: Vec<HydratePart>,
) -> ChemicalFormula
pub fn new( main_part: FormulaPart, hydrate_parts: Vec<HydratePart>, ) -> ChemicalFormula
Creates a chemical formula from a main part and hydrate parts.
pub fn parse(input: &str) -> Result<ChemicalFormula, FormulaParseError>
pub fn parse(input: &str) -> Result<ChemicalFormula, FormulaParseError>
Parses a chemical formula string.
§Errors
Returns FormulaParseError when the input is empty or does not match the supported
lightweight formula grammar.
pub const fn main_part(&self) -> &FormulaPart
pub const fn main_part(&self) -> &FormulaPart
Returns the main formula part.
pub fn hydrate_parts(&self) -> &[HydratePart]
pub fn hydrate_parts(&self) -> &[HydratePart]
Returns hydrate parts after the main formula part.
pub fn element_counts(&self) -> BTreeMap<String, u64>
pub fn element_counts(&self) -> BTreeMap<String, u64>
Returns expanded element counts for the full formula.
Trait Implementations§
§impl AsRef<ChemicalFormula> for CompoundFormula
impl AsRef<ChemicalFormula> for CompoundFormula
§fn as_ref(&self) -> &ChemicalFormula
fn as_ref(&self) -> &ChemicalFormula
Converts this type into a shared reference of the (usually inferred) input type.
§impl AsRef<ChemicalFormula> for EmpiricalFormula
impl AsRef<ChemicalFormula> for EmpiricalFormula
§fn as_ref(&self) -> &ChemicalFormula
fn as_ref(&self) -> &ChemicalFormula
Converts this type into a shared reference of the (usually inferred) input type.
§impl AsRef<ChemicalFormula> for IonFormula
impl AsRef<ChemicalFormula> for IonFormula
§fn as_ref(&self) -> &ChemicalFormula
fn as_ref(&self) -> &ChemicalFormula
Converts this type into a shared reference of the (usually inferred) input type.
§impl AsRef<ChemicalFormula> for MolecularFormula
impl AsRef<ChemicalFormula> for MolecularFormula
§fn as_ref(&self) -> &ChemicalFormula
fn as_ref(&self) -> &ChemicalFormula
Converts this type into a shared reference of the (usually inferred) input type.
§impl AsRef<ChemicalFormula> for MolecularFormula
impl AsRef<ChemicalFormula> for MolecularFormula
§fn as_ref(&self) -> &ChemicalFormula
fn as_ref(&self) -> &ChemicalFormula
Converts this type into a shared reference of the (usually inferred) input type.
§impl Clone for ChemicalFormula
impl Clone for ChemicalFormula
§fn clone(&self) -> ChemicalFormula
fn clone(&self) -> ChemicalFormula
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read more§impl Debug for ChemicalFormula
impl Debug for ChemicalFormula
§impl Display for ChemicalFormula
impl Display for ChemicalFormula
§impl From<ChemicalFormula> for CompoundFormula
impl From<ChemicalFormula> for CompoundFormula
§fn from(value: ChemicalFormula) -> CompoundFormula
fn from(value: ChemicalFormula) -> CompoundFormula
Converts to this type from the input type.
§impl From<ChemicalFormula> for EmpiricalFormula
impl From<ChemicalFormula> for EmpiricalFormula
§fn from(value: ChemicalFormula) -> EmpiricalFormula
fn from(value: ChemicalFormula) -> EmpiricalFormula
Converts to this type from the input type.
§impl From<ChemicalFormula> for IonFormula
impl From<ChemicalFormula> for IonFormula
§fn from(value: ChemicalFormula) -> IonFormula
fn from(value: ChemicalFormula) -> IonFormula
Converts to this type from the input type.
§impl From<ChemicalFormula> for MolecularFormula
impl From<ChemicalFormula> for MolecularFormula
§fn from(value: ChemicalFormula) -> MolecularFormula
fn from(value: ChemicalFormula) -> MolecularFormula
Converts to this type from the input type.
§impl From<ChemicalFormula> for MolecularFormula
impl From<ChemicalFormula> for MolecularFormula
§fn from(value: ChemicalFormula) -> MolecularFormula
fn from(value: ChemicalFormula) -> MolecularFormula
Converts to this type from the input type.
§impl FromStr for ChemicalFormula
impl FromStr for ChemicalFormula
§type Err = FormulaParseError
type Err = FormulaParseError
The associated error which can be returned from parsing.
§fn from_str(
input: &str,
) -> Result<ChemicalFormula, <ChemicalFormula as FromStr>::Err>
fn from_str( input: &str, ) -> Result<ChemicalFormula, <ChemicalFormula as FromStr>::Err>
Parses a string
s to return a value of this type. Read more§impl PartialEq for ChemicalFormula
impl PartialEq for ChemicalFormula
impl Eq for ChemicalFormula
impl StructuralPartialEq for ChemicalFormula
Auto Trait Implementations§
impl Freeze for ChemicalFormula
impl RefUnwindSafe for ChemicalFormula
impl Send for ChemicalFormula
impl Sync for ChemicalFormula
impl Unpin for ChemicalFormula
impl UnsafeUnpin for ChemicalFormula
impl UnwindSafe for ChemicalFormula
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more