| Crates.io | chemistru-elements-inner |
| lib.rs | chemistru-elements-inner |
| version | 1.1.0 |
| created_at | 2025-09-17 03:23:22.946067+00 |
| updated_at | 2025-09-17 03:23:22.946067+00 |
| description | Basic Elemental Representation |
| homepage | https://github.com/Ross-Morgan/chemistru/tree/main/chemistru-elements-inner |
| repository | https://github.com/Ross-Morgan/chemistru |
| max_upload_size | |
| id | 1842718 |
| size | 175,860 |
Provides one of two functions:
ToTokens from the quote library, allowing use with related chemistru crates.The elements are stored in the lazily-initialised vector chemistru_elements::ELEMENTS
// Atomic (proton) number, in this case, hydrogen
let z = 1;
// Static reference to the struct representing hydrogen
let element = chemistru_elements::element_from_atomic_number(z);
// 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 = chemistru_elements::element_from_name(name_1)
let element_2 = chemistru_elements::element_from_name(name_2)
assert_eq!(element_1, element_2)
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.
operation_user_sees();
// May cause a tangible delay (interacting with io)
let element = ELEMENT[0];
operation_user_sees();
// Pre-initialise the vector of elements
chemistru_elements::preload_elements();
operation_user_sees();
// Virually no delay (trivial operation)
let element = ELEMENT[0];
operation_user_sees();