pub struct Element(/* private fields */);Expand description
A chemical element, represented by its atomic number.
Element::UNKNOWN means no element could be determined. That is a
different statement from an element being absent from a selection, and the
two are never conflated.
§Examples
use molframe_core::Element;
assert_eq!(Element::from_symbol("FE"), Some(Element::IRON));
assert_eq!(Element::IRON.symbol(), "Fe");
assert_eq!(Element::from_symbol("Unobtainium"), None);Implementations§
Source§impl Element
impl Element
Sourcepub const PHOSPHORUS: Element
pub const PHOSPHORUS: Element
Phosphorus.
Sourcepub const CALCIUM: Element
pub const CALCIUM: Element
Calcium — what CA means when the atom name starts in the first column.
Sourcepub const MAX_ATOMIC_NUMBER: u8 = 118
pub const MAX_ATOMIC_NUMBER: u8 = 118
The largest atomic number this type represents.
Sourcepub const fn from_atomic_number(z: u8) -> Element
pub const fn from_atomic_number(z: u8) -> Element
Creates an element from an atomic number, or Element::UNKNOWN when the
number is past the end of the periodic table.
Sourcepub const fn atomic_number(self) -> u8
pub const fn atomic_number(self) -> u8
Returns the atomic number, which doubles as this element’s bit position in a chunk’s element set.
Sourcepub fn symbol(self) -> &'static str
pub fn symbol(self) -> &'static str
Returns the capitalised symbol, or the empty string when unknown.
Sourcepub const fn is_unknown(self) -> bool
pub const fn is_unknown(self) -> bool
Returns true when no element could be determined.
Sourcepub const fn is_hydrogen(self) -> bool
pub const fn is_hydrogen(self) -> bool
Returns true for hydrogen.
Hydrogen presence is summarised per chunk and is what a policy that excludes or includes hydrogens tests.
Sourcepub fn from_symbol(text: &str) -> Option<Element>
pub fn from_symbol(text: &str) -> Option<Element>
Parses a symbol, ignoring surrounding whitespace and letter case.
D and T are hydrogen isotopes, not elements, and resolve to
Element::HYDROGEN; neutron structures spell deuterium that way.
Sourcepub fn infer_from_pdb_atom_name(field: &str) -> Element
pub fn infer_from_pdb_atom_name(field: &str) -> Element
Recovers an element from a fixed-column atom-name field.
field must be the four-column name untrimmed, because the leading
space is the only thing that distinguishes the two readings:
- a name that does not start in the first column has a one-letter element, taken from its first letter;
- a name that starts in the first column has a two-letter element when its first two characters name one, and a one-letter element otherwise.
This is why " CA " in an amino acid is carbon and "CA " in an ion is
calcium. Readers call this only under an explicit missing-element policy;
a declared element always wins and inference is recorded as a warning,
because the rule is a convention that files are free to violate.
Sourcepub fn infer_from_name(name: &str) -> Element
pub fn infer_from_name(name: &str) -> Element
Recovers an element from a name with no column convention.
Tries the leading two letters, then the leading one. Without a leading
space to disambiguate, CA reads as calcium; formats that lack the
convention make the element column mandatory for exactly this reason.
Trait Implementations§
impl Copy for Element
impl Eq for Element
Source§impl FromIterator<Element> for ElementMask
impl FromIterator<Element> for ElementMask
Source§fn from_iter<T>(iter: T) -> ElementMaskwhere
T: IntoIterator<Item = Element>,
fn from_iter<T>(iter: T) -> ElementMaskwhere
T: IntoIterator<Item = Element>,
Source§impl Ord for Element
impl Ord for Element
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Element
impl PartialOrd for Element
impl StructuralPartialEq for Element
Auto Trait Implementations§
impl Freeze for Element
impl RefUnwindSafe for Element
impl Send for Element
impl Sync for Element
impl Unpin for Element
impl UnsafeUnpin for Element
impl UnwindSafe for Element
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more