pub const fn antiparticle(kind: ParticleKind) -> Option<ParticleKind>Expand description
Returns the modeled antiparticle for kind.
Self-conjugate particles such as the photon return themselves.
ยงExamples
use use_particle::{ParticleKind, antiparticle};
assert_eq!(antiparticle(ParticleKind::Electron), Some(ParticleKind::Positron));
assert_eq!(antiparticle(ParticleKind::Photon), Some(ParticleKind::Photon));Examples found in repository?
examples/facade_particle.rs (line 14)
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}