Skip to main content

Element

Struct Element 

Source
pub struct Element(/* private fields */);
Expand description

An element represented as its atomic number, wrapped in a newtype.

Zero-copy: implements Copy; comparison and hashing are O(1).

Implementations§

Source§

impl Element

Source

pub const H: Element

Source

pub const HE: Element

Source

pub const LI: Element

Source

pub const BE: Element

Source

pub const B: Element

Source

pub const C: Element

Source

pub const N: Element

Source

pub const O: Element

Source

pub const F: Element

Source

pub const NE: Element

Source

pub const NA: Element

Source

pub const MG: Element

Source

pub const AL: Element

Source

pub const SI: Element

Source

pub const P: Element

Source

pub const S: Element

Source

pub const CL: Element

Source

pub const AR: Element

Source

pub const K: Element

Source

pub const CA: Element

Source

pub const SC: Element

Source

pub const TI: Element

Source

pub const V: Element

Source

pub const CR: Element

Source

pub const MN: Element

Source

pub const FE: Element

Source

pub const CO: Element

Source

pub const NI: Element

Source

pub const CU: Element

Source

pub const ZN: Element

Source

pub const GA: Element

Source

pub const GE: Element

Source

pub const AS: Element

Source

pub const SE: Element

Source

pub const BR: Element

Source

pub const KR: Element

Source

pub const RB: Element

Source

pub const SR: Element

Source

pub const Y: Element

Source

pub const ZR: Element

Source

pub const NB: Element

Source

pub const MO: Element

Source

pub const TC: Element

Source

pub const RU: Element

Source

pub const RH: Element

Source

pub const PD: Element

Source

pub const AG: Element

Source

pub const CD: Element

Source

pub const IN: Element

Source

pub const SN: Element

Source

pub const SB: Element

Source

pub const TE: Element

Source

pub const I: Element

Source

pub const XE: Element

Source

pub const CS: Element

Source

pub const BA: Element

Source

pub const LA: Element

Source

pub const CE: Element

Source

pub const PR: Element

Source

pub const ND: Element

Source

pub const PM: Element

Source

pub const SM: Element

Source

pub const EU: Element

Source

pub const GD: Element

Source

pub const TB: Element

Source

pub const DY: Element

Source

pub const HO: Element

Source

pub const ER: Element

Source

pub const TM: Element

Source

pub const YB: Element

Source

pub const LU: Element

Source

pub const HF: Element

Source

pub const TA: Element

Source

pub const W: Element

Source

pub const RE: Element

Source

pub const OS: Element

Source

pub const IR: Element

Source

pub const PT: Element

Source

pub const AU: Element

Source

pub const HG: Element

Source

pub const TL: Element

Source

pub const PB: Element

Source

pub const BI: Element

Source

pub const PO: Element

Source

pub const AT: Element

Source

pub const RN: Element

Source

pub const FR: Element

Source

pub const RA: Element

Source

pub const AC: Element

Source

pub const TH: Element

Source

pub const PA: Element

Source

pub const U: Element

Source

pub const NP: Element

Source

pub const PU: Element

Source

pub const AM: Element

Source

pub const CM: Element

Source

pub const BK: Element

Source

pub const CF: Element

Source

pub const ES: Element

Source

pub const FM: Element

Source

pub const MD: Element

Source

pub const NO: Element

Source

pub const LR: Element

Source

pub const RF: Element

Source

pub const DB: Element

Source

pub const SG: Element

Source

pub const BH: Element

Source

pub const HS: Element

Source

pub const MT: Element

Source

pub const DS: Element

Source

pub const RG: Element

Source

pub const CN: Element

Source

pub const NH: Element

Source

pub const FL: Element

Source

pub const MC: Element

Source

pub const LV: Element

Source

pub const TS: Element

Source

pub const OG: Element

Source

pub const fn from_atomic_number(n: u8) -> Option<Self>

Create an Element from an atomic number. Returns None if n is outside 1–118.

Source

pub fn from_symbol(s: &str) -> Option<Self>

Create an Element from its symbol (title-case, e.g. “C”, “Cl”). Case-sensitive: “C” is carbon, “c” is not accepted.

Source

pub fn symbol(self) -> &'static str

Return the IUPAC element symbol (title-case).

Source

pub fn atomic_number(self) -> u8

Return the atomic number (1–118).

Source

pub fn is_organic_subset(self) -> bool

Returns true if this element is in the OpenSMILES organic subset (B, C, N, O, P, S, F, Cl, Br, I) — these may carry implicit H without brackets.

Source

pub fn normal_valences(self) -> &'static [u8]

Normal valence list (ascending). Empty = undefined (transition metals, etc.). Used for computing implicit H counts in organic-subset atoms.

Trait Implementations§

Source§

impl Clone for Element

Source§

fn clone(&self) -> Element

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Element

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Element

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Hash for Element

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for Element

Source§

fn cmp(&self, other: &Element) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl PartialEq for Element

Source§

fn eq(&self, other: &Element) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Element

Source§

fn partial_cmp(&self, other: &Element) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Copy for Element

Source§

impl Eq for Element

Source§

impl StructuralPartialEq for Element

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.