chemistru-elements-1.0.0 has been yanked.
Chemistru Elements
Provides a static vec of all the elements, with data loaded from a JSON file.
Static Vector
The elements are stored in the lazily-initialised vector chemistru_elements::ELEMENTS
Getting Elements By Atomic (Proton) Number
// Atomic (proton) number, in this case, hydrogen
let z = 1;
// Static reference to the struct representing hydrogen
let element = element_from_atomic_number;
Getting Elements By Name
// Name of element
// Case insensitive and accepts multiple spellings
// i.e. 'Cesium', 'Caesium', 'CaEsIuM' will all work
let name_1 = "caesium";
let name_2 = "cesium";
let element_1 = element_from_name
let element_2 = element_from_name
assert_eq!
Preloading Elements
Since the static vector of Elements is created using lazy_static, it will not be initialised until it is used (lazy initialisation)
This ensures that the static vector of Elements is initialised. This is useful if initialising the element vector later would cause some tangible delay for the user.
Without
operation_user_sees;
// May cause a tangible delay (interacting with io)
let element = ELEMENT;
operation_user_sees;
With
// Pre-initialise the vector of elements
preload_elements;
operation_user_sees;
// Virually no delay (trivial operation)
let element = ELEMENT;
operation_user_sees;