pub struct AtomRef<'a> { /* private fields */ }
Expand description
An analog to a reference to an atom (&Atom
)
Methods from Deref<Target = Atom>§
sourcepub fn mass(&self) -> f64
pub fn mass(&self) -> f64
Get the atom mass, in atomic mass units.
Example
let atom = Atom::new("He");
assert_eq!(atom.mass(), 4.002602);
sourcepub fn charge(&self) -> f64
pub fn charge(&self) -> f64
Get the atom charge, in number of the electron charge e.
Example
let atom = Atom::new("He");
assert_eq!(atom.charge(), 0.0);
sourcepub fn atomic_type(&self) -> String
pub fn atomic_type(&self) -> String
sourcepub fn full_name(&self) -> String
pub fn full_name(&self) -> String
Try to get the full name of the atom from the atomic type. For example, the full name of “He” is “Helium”, and so on. If the name can not be found, this function returns the empty string.
Example
let atom = Atom::new("Zn");
assert_eq!(atom.full_name(), "Zinc");
sourcepub fn vdw_radius(&self) -> f64
pub fn vdw_radius(&self) -> f64
Try to get the Van der Waals radius of the atom from the atomic type. If the radius can not be found, returns 0.
Example
assert_eq!(Atom::new("He").vdw_radius(), 1.4);
assert_eq!(Atom::new("Xxx").vdw_radius(), 0.0);
sourcepub fn covalent_radius(&self) -> f64
pub fn covalent_radius(&self) -> f64
Try to get the covalent radius of the atom from the atomic type. If the radius can not be found, returns 0.
Example
assert_eq!(Atom::new("He").covalent_radius(), 0.32);
assert_eq!(Atom::new("Xxx").covalent_radius(), 0.0);
sourcepub fn atomic_number(&self) -> u64
pub fn atomic_number(&self) -> u64
Try to get the atomic number of the atom from the atomic type. If the number can not be found, returns 0.
Example
assert_eq!(Atom::new("He").atomic_number(), 2);
assert_eq!(Atom::new("Xxx").atomic_number(), 0);
sourcepub fn get(&self, name: &str) -> Option<Property>
pub fn get(&self, name: &str) -> Option<Property>
Get a property with the given name
in this atom, if it exist.
Examples
let mut atom = Atom::new("He");
atom.set("foo", Property::Double(22.2));
assert_eq!(atom.get("foo"), Some(Property::Double(22.2)));
assert_eq!(atom.get("Bar"), None);
sourcepub fn properties(&self) -> PropertiesIter<'_> ⓘ
pub fn properties(&self) -> PropertiesIter<'_> ⓘ
Get an iterator over all (name, property) pairs for this atom
Examples
let mut atom = Atom::new("He");
atom.set("foo", Property::Double(22.2));
atom.set("bar", Property::Bool(false));
for (name, property) in atom.properties() {
if name == "foo" {
assert_eq!(property, Property::Double(22.2));
} else if name == "bar" {
assert_eq!(property, Property::Bool(false));
}
}