Expand description
§use-element
Small chemical element primitives and static lookup helpers.
Auditable periodic-table data for direct Rust code without runtime fetches or heavyweight chemistry frameworks.
Surface · Symbol lookup · Installation · Examples · Scope
use-element provides a small Element value type plus direct lookup helpers backed by a static table for elements 1 through 118. It is intended as the foundational chemistry primitive crate for the RustUse chemistry workspace.
§What this crate provides
| Item | Purpose |
|---|---|
Element | Small copyable element value with atomic number, symbol, name, mass, period, and group |
all_elements() | Full static slice of the known elements |
element_by_symbol() | Symbol lookup with ASCII case-insensitive matching |
element_by_atomic_number() | Direct atomic-number lookup |
element_name() | Symbol-to-name helper |
element_symbol() | Atomic-number-to-symbol helper |
§Symbol lookup behavior
Symbol lookup trims surrounding whitespace and compares symbols with ASCII case-insensitive matching. That means "Na", "na", and " NA " all resolve to sodium.
§Installation
[dependencies]
use-element = "0.1.0"§Quick examples
§Lookup by symbol
use use_element::{element_by_symbol, element_name};
let carbon = element_by_symbol("c").unwrap();
assert_eq!(carbon.atomic_number, 6);
assert_eq!(carbon.name, "Carbon");
assert_eq!(element_name("C"), Some("Carbon"));§Lookup by atomic number
use use_element::{element_by_atomic_number, element_symbol};
let oxygen = element_by_atomic_number(8).unwrap();
assert_eq!(oxygen.symbol, "O");
assert_eq!(oxygen.period, 2);
assert_eq!(oxygen.group, Some(16));
assert_eq!(element_symbol(79), Some("Au"));§Scope
- Static periodic-table data only.
- No runtime network access.
- No isotope tables.
- No molecular or reaction modeling.
- Conservative group assignment for lanthanides and actinides via
None. Basic chemical element primitives and static lookup helpers.
Structs§
- Element
- Small copyable element metadata suitable for direct lookup helpers.
Functions§
- all_
elements - Returns the full static element table in atomic-number order.
- element_
by_ atomic_ number - Looks up an element by atomic number.
- element_
by_ symbol - Looks up an element by symbol using ASCII case-insensitive matching.
- element_
name - Returns the element name for a symbol lookup.
- element_
symbol - Returns the element symbol for an atomic number.