// 3rd party imports use anyhow::{bail, Result}; // Subatomic particles {% for record in data %} pub const {{ record.0|upper_snake_case }}: SubatomicParticle = SubatomicParticle { name: "{{ record.0|capitalize }}", mass: {{ record.1|f64_to_string }}, }; {% endfor %} /// Array of canoncial amino acids /// pub const SUBATOMIC_PARTICLES: [SubatomicParticle; {{ data|len }}] = [ {% for record in data %} {{ record.0|upper_snake_case }}, {% endfor %} ]; /// Get subatomic particle by name /// /// # Arguments /// `name` - Name of subatomic particle /// pub fn get_subatomic_particle_by_name(name: &str) -> Result<&'static SubatomicParticle> { match name.to_ascii_lowercase().as_str() { {% for record in data %} "{{ record.0|lower }}" => Ok(&{{ record.0|upper_snake_case }}), {% endfor %} _=> bail!("Invalid subatomic particle name: {}", name), } }