| Crates.io | molcore |
| lib.rs | molcore |
| version | 0.1.0 |
| created_at | 2025-10-07 18:27:24.277882+00 |
| updated_at | 2025-10-07 18:27:24.277882+00 |
| description | Molcrafts molecular modeling core library |
| homepage | https://github.com/Roy-Kid/molcore |
| repository | https://github.com/Roy-Kid/molcore |
| max_upload_size | |
| id | 1872164 |
| size | 11,768 |
A Rust library providing core molecular modeling functionality, including element data and molecular representations.
Note: This is a work-in-progress backend for molpy.
๐งช Element Data: Complete periodic table information
๐ Zero Dependencies: Lightweight and fast
๐ Type Safe: Leverages Rust's type system for safety
๐ฆ no_std Compatible: Can be used in embedded environments
Add this to your Cargo.toml:
[dependencies]
molcore = "0.1"
use molcore::core::Element;
fn main() {
// Look up elements by atomic number
let hydrogen = Element::by_number(1);
println!("{}: {}", hydrogen.symbol, hydrogen.name);
// Output: H: Hydrogen
// Look up elements by symbol (case-insensitive)
let h1 = Element::by_symbol("H");
let h2 = Element::by_symbol("h");
assert_eq!(h1 as *const _, h2 as *const _); // Same reference
// Access element properties
println!("Atomic mass: {}", hydrogen.atomic_mass);
println!("Atomic number: {}", hydrogen.z);
}
Element Structpub struct Element {
pub z: u8, // Atomic number
pub symbol: &'static str, // Element symbol
pub name: &'static str, // Element name
pub atomic_mass: f32, // Atomic mass in u
}
Element::by_number(z: u8) -> &'static Element - Find element by atomic numberElement::by_symbol(sym: &str) -> &'static Element - Find element by symbol (case-insensitive)Both lookup methods will panic with descriptive messages if the element is not found:
by_number: panics with "invalid atomic number"by_symbol: panics with "invalid symbol"cargo test
cargo doc --open
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the BSD 3-Clause License - see the LICENSE file for details.
Part of the MolCrafts project ecosystem.