Skip to main content

Element

Struct Element 

Source
pub struct Element {
    pub atomic_num: u8,
    pub symbol: &'static str,
    pub period: u8,
    pub rcov: f32,
    pub rvdw: f32,
    pub mass: f64,
    pub outer_electrons: u8,
    pub common_isotope: u16,
    pub common_isotope_mass: f64,
    pub electronegativity: Option<f64>,
    pub valences: &'static [i8],
}
Expand description

单个元素的静态数据。

Fields§

§atomic_num: u8

原子序数。0 为 SMILES 通配原子 *

§symbol: &'static str

元素符号(首字母大写形式)

§period: u8

周期

§rcov: f32

共价半径 (Å)

§rvdw: f32

范德华半径 (Å)

§mass: f64

标准原子量。

f64 而不是 f32:上游表里写的是 12.011,存成 f32 再读回来是 12.0109996…,差 3e-7。这点差在化学上无关紧要,可它让“与参照逐位相同“ 变成“与参照差在末几位“,判据只好配一个容差 —— 容差一旦有了,就再也 分不出“存储精度“和“抄错了一位“。电负性同理。

§outer_electrons: u8

外层电子数

§common_isotope: u16

最常见同位素的质量数

§common_isotope_mass: f64

最常见同位素的精确质量

§electronegativity: Option<f64>

Pauling 电负性。

None 表示该元素没有公认的 Pauling 值(稀有气体 He/Ne/Ar/Rn、 Pm、Eu、Tb、Yb、Fr 等),不是“还没填“。两者必须能被下游分开: 拿一个默认数顶上去,调用方就再也看不出这一格是量出来的还是补的。

§valences: &'static [i8]

默认价列表。-1 表示无价约束(该元素不参与隐式氢推断)。

Implementations§

Source§

impl Element

Source

pub fn has_valence_constraint(&self) -> bool

该元素是否有价约束。无约束的元素(多数金属)不推断隐式氢。

Source

pub fn default_valence_for(&self, used: i8) -> Option<i8>

给定已用价数,返回应当采用的默认价。

规则:取第一个 ≥ 已用价的默认价;若全部小于已用价, 说明是超价(hypervalent),返回 None,由调用方决定是报错还是放行。

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 Copy for Element

Source§

impl Debug for Element

Source§

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

Formats the value using the given formatter. Read more

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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.