pub struct OxidationState { /* private fields */ }Expand description
A validated oxidation-state value.
Implementations§
Source§impl OxidationState
impl OxidationState
Sourcepub const fn new(
sign: OxidationSign,
magnitude: OxidationMagnitude,
) -> Result<Self, OxidationStateValidationError>
pub const fn new( sign: OxidationSign, magnitude: OxidationMagnitude, ) -> Result<Self, OxidationStateValidationError>
Creates an oxidation state from a sign and magnitude.
§Errors
Returns OxidationStateValidationError::ZeroSignedMagnitude when a positive or
negative state uses zero magnitude, or
OxidationStateValidationError::NonZeroZeroMagnitude when a zero state uses a
nonzero magnitude.
Sourcepub fn positive(magnitude: u8) -> Result<Self, OxidationStateValidationError>
pub fn positive(magnitude: u8) -> Result<Self, OxidationStateValidationError>
Creates a positive oxidation state.
§Errors
Returns OxidationStateValidationError::ZeroSignedMagnitude when magnitude is
zero, or OxidationStateValidationError::MagnitudeAboveMaximum when it is above
the supported range.
Sourcepub fn negative(magnitude: u8) -> Result<Self, OxidationStateValidationError>
pub fn negative(magnitude: u8) -> Result<Self, OxidationStateValidationError>
Creates a negative oxidation state.
§Errors
Returns OxidationStateValidationError::ZeroSignedMagnitude when magnitude is
zero, or OxidationStateValidationError::MagnitudeAboveMaximum when it is above
the supported range.
Sourcepub const fn sign(self) -> OxidationSign
pub const fn sign(self) -> OxidationSign
Returns the oxidation-state sign.
Sourcepub const fn magnitude(self) -> OxidationMagnitude
pub const fn magnitude(self) -> OxidationMagnitude
Returns the oxidation-state magnitude.
Sourcepub const fn magnitude_value(self) -> u8
pub const fn magnitude_value(self) -> u8
Returns the oxidation-state magnitude value.
Sourcepub const fn signed_value(self) -> i8
pub const fn signed_value(self) -> i8
Returns the signed oxidation-state value.
Sourcepub const fn is_positive(self) -> bool
pub const fn is_positive(self) -> bool
Returns true for positive oxidation states.
Sourcepub const fn is_negative(self) -> bool
pub const fn is_negative(self) -> bool
Returns true for negative oxidation states.
Trait Implementations§
Source§impl Clone for OxidationState
impl Clone for OxidationState
Source§fn clone(&self) -> OxidationState
fn clone(&self) -> OxidationState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for OxidationState
impl Debug for OxidationState
Source§impl Default for OxidationState
impl Default for OxidationState
Source§impl Display for OxidationState
impl Display for OxidationState
Source§impl Hash for OxidationState
impl Hash for OxidationState
Source§impl Ord for OxidationState
impl Ord for OxidationState
Source§fn cmp(&self, other: &OxidationState) -> Ordering
fn cmp(&self, other: &OxidationState) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for OxidationState
impl PartialEq for OxidationState
Source§fn eq(&self, other: &OxidationState) -> bool
fn eq(&self, other: &OxidationState) -> bool
self and other values to be equal, and is used by ==.