pub struct Electronvolt(pub f64);Expand description
A value in electronvolts (eV).
Basic arithmetic is implemented for convenience, and the underlying f64 value is accessible as a tuple field.
§Example
use mendeleev::Electronvolt;
use core::cmp::Ordering;
let value1 = Electronvolt(1.0);
let value2 = Electronvolt(2.0);
assert_eq!(value1.0, 1.0);
assert!(value1 < value2);
assert_eq!(value1.total_cmp(&value2), Ordering::Less);
assert_eq!(value1 + value2, Electronvolt(3.0));
assert_eq!(value1 - value2, Electronvolt(-1.0));
assert_eq!(value1 * 5.0, Electronvolt(5.0));
assert_eq!(value1 / 4.0, Electronvolt(0.25));Tuple Fields§
§0: f64Implementations§
Source§impl Electronvolt
impl Electronvolt
Sourcepub fn total_cmp(&self, other: &Self) -> Ordering
pub fn total_cmp(&self, other: &Self) -> Ordering
Return the ordering between self and other.
This simply calls f64::total_cmp on the inner value.
Trait Implementations§
Source§impl Add for Electronvolt
impl Add for Electronvolt
Source§impl Clone for Electronvolt
impl Clone for Electronvolt
Source§fn clone(&self) -> Electronvolt
fn clone(&self) -> Electronvolt
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 moreSource§impl Debug for Electronvolt
impl Debug for Electronvolt
Source§impl Display for Electronvolt
impl Display for Electronvolt
Source§fn fmt(&self, f: &mut Formatter<'_>) -> Result
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Displays the value along with the unit. Supports numeric formatting.
A space is added between the number and the unit, in accordance with the SI convention.
§Example
use mendeleev::Electronvolt;
let value = Electronvolt(1.2345);
assert_eq!(format!("{value:.1}"), "1.2 eV");Source§impl Div<f64> for Electronvolt
impl Div<f64> for Electronvolt
Source§impl Mul<f64> for Electronvolt
impl Mul<f64> for Electronvolt
Source§impl PartialEq for Electronvolt
impl PartialEq for Electronvolt
Source§impl PartialOrd for Electronvolt
impl PartialOrd for Electronvolt
Source§impl Sub for Electronvolt
impl Sub for Electronvolt
impl Copy for Electronvolt
impl StructuralPartialEq for Electronvolt
Auto Trait Implementations§
impl Freeze for Electronvolt
impl RefUnwindSafe for Electronvolt
impl Send for Electronvolt
impl Sync for Electronvolt
impl Unpin for Electronvolt
impl UnwindSafe for Electronvolt
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