3 releases

0.1.4 Oct 27, 2023
0.1.3 Oct 4, 2023
0.1.2 Oct 3, 2023
0.1.0 Oct 2, 2023

#403 in Science

34 downloads per month
Used in molrs

MIT license

60KB
965 lines

pertable

Periodic table in rust.


lib.rs:

Periodic table in Rust

Provides an Element enum which has a few utility functions that are useful for general cheminformatics programming. Elements can be created either from the atomic number or the atomic symbol using the TryFrom and FromStr respectively.

This library provides a few utility functions useful for cheminformatics:

  • atomic_number
  • atomic_symbol
  • atomic_weight (WIP!)
  • n_valence_electrons (for SMILES parsing/perception, not for general use)
  • valence (for SMILES parsing/perception, not for general use)

This library has its own Error enum with the following variants:

  • InvalidAtomicNumber
  • InvalidAtomicSymbol
  • InvalidIsotope
  • InvalidFormalCharge

Here's some example code:

use pertable::Element;

let element = Element::C;
assert_eq!(element.atomic_number(), 6);
assert_eq!(element.atomic_symbol(), "C".to_owned());
assert_eq!(element.atomic_weight(None).unwrap(), 12.0106);
assert_eq!(element.n_valence_electrons(0).unwrap(), 4);
assert_eq!(element.valence(0).unwrap(), 4);

No runtime deps