Crates.io | mendeleev |
lib.rs | mendeleev |
version | 0.8.1 |
source | src |
created_at | 2022-11-05 13:24:10.653626 |
updated_at | 2024-06-05 20:58:47.583824 |
description | List of chemical elements, their isotopes, and their properties |
homepage | https://gitlab.com/ygor.souza/mendeleev |
repository | https://gitlab.com/ygor.souza/mendeleev |
max_upload_size | |
id | 705782 |
size | 752,616 |
Information on chemical elements and their isotopes
Mendeleev is a crate containing all known chemical elements as an enum and as a list, as well as methods that return some properties for each of them.
Get data on a specific element
use mendeleev::Element;
let element = Element::Si;
assert_eq!(element.atomic_number(), 14);
assert_eq!(element.name(), "Silicon");
assert_eq!(format!("{}", element.electronic_configuration()), "[Ne] 3s² 3p²");
Search the list of elements
use mendeleev::{Element, Kelvin};
// Find the element with the highest value for a given property
let highest_melting_point = Element::iter().reduce(|acc, e| {
core::cmp::max_by(acc, e, |e1, e2| {
e1.melting_point()
.unwrap_or(Kelvin(0.0))
.total_cmp(&e2.melting_point().unwrap_or(Kelvin(0.0)))
})
});
assert_eq!(highest_melting_point, Some(Element::C));
// Iterate through the elements with no known year of discovery
let mut ancient_elements = Element::iter()
.filter(|e| matches!(e.year_discovered(), mendeleev::YearDiscovered::Ancient));
assert_eq!(ancient_elements.next(), Some(Element::C));
assert_eq!(ancient_elements.next(), Some(Element::Al));
// Find an element by name
let iron = Element::iter().find(|e| e.name().eq_ignore_ascii_case("iron"));
assert_eq!(iron, Some(Element::Fe));
It also contains most of the known isotopes for each element (naturally occurring, synthetic, or theoretical), accessible via a similar API as the elements themselves.
serde
const
or 'static
Display
build.rs
file. All the data is directly in the codeThe data from this crate comes from the following sources:
Density, electron affinity, and ionization energy:
Melting point, boiling point:
Other properties:
Note that this crate is not maintained by the same authors as the PyPI package.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as below, without any additional terms or conditions.
Licensed under either of
at your option.