pub struct Element<'a> {
pub symbol: &'a str,
pub protons: u8,
pub electrons: u8,
pub neutrons: u8,
pub atomic_weight: f32,
pub pauling_en: f32,
}
Expand description
The struct for storing a chemical element.
Fields§
§symbol: &'a str
§protons: u8
§electrons: u8
§neutrons: u8
§atomic_weight: f32
§pauling_en: f32
Implementations§
source§impl<'a> Element<'a>
impl<'a> Element<'a>
sourcepub const fn new(
symbol: &str,
protons: u8,
electrons: u8,
neutrons: u8,
atomic_weight: f32,
pauling_en: f32
) -> Element<'_>
pub const fn new( symbol: &str, protons: u8, electrons: u8, neutrons: u8, atomic_weight: f32, pauling_en: f32 ) -> Element<'_>
Create a new, custom chemical element.
Arguments
symbol: &str
- The element symbol.protons: u8
- The number of protons.electrons: u8
- The number of electrons.neutrons: u8
- The number of neutrons.atomic_weight: f32
- The weighted average of all isotopes.pauling_en: f32
- The electronegativity after Pauling.
Examples
use lib_rapid::chem::elements::Element;
let elem = Element::new("Xy", 255, 255, 255, 510.7, 6.54); // Fictional element.
assert_eq!(elem.atomic_weight, 510.7);
sourcepub const fn mass_number(&self) -> u16
pub const fn mass_number(&self) -> u16
Lets you get the mass number of a direct element.
Examples
use lib_rapid::chem::elements::Element;
let elem = Element::new("Xy", 255, 255, 255, 510.7, 6.54); // Fictional element.
assert_eq!(elem.mass_number(), 510);
Trait Implementations§
source§impl<'a> PartialEq for Element<'a>
impl<'a> PartialEq for Element<'a>
impl<'a> Copy for Element<'a>
impl<'a> StructuralPartialEq for Element<'a>
Auto Trait Implementations§
impl<'a> RefUnwindSafe for Element<'a>
impl<'a> Send for Element<'a>
impl<'a> Sync for Element<'a>
impl<'a> Unpin for Element<'a>
impl<'a> UnwindSafe for Element<'a>
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