Skip to main content

charge

Function charge 

Source
pub const fn charge(kind: ParticleKind) -> ElementaryCharge
Expand description

Returns the exact charge for kind.

ยงExamples

use use_particle::{ParticleKind, charge};

assert_eq!(charge(ParticleKind::Electron).thirds, -3);
assert_eq!(charge(ParticleKind::UpQuark).thirds, 2);
Examples found in repository?
examples/facade_particle.rs (line 11)
7fn main() {
8    let electron = Particle::new(ParticleKind::Electron);
9
10    assert_eq!(electron.family(), ParticleFamily::Lepton);
11    assert_eq!(charge(ParticleKind::Electron).thirds, -3);
12    assert_eq!(spin(ParticleKind::Photon).doubled, 2);
13    assert_eq!(
14        antiparticle(ParticleKind::Electron),
15        Some(ParticleKind::Positron)
16    );
17    assert!(approx_eq(electron.charge().as_elementary_units(), -1.0,));
18}