pub struct Particle {
pub kind: ParticleKind,
}Expand description
A lightweight particle wrapper that delegates to the free helper functions.
Fields§
§kind: ParticleKindThe underlying particle kind.
Implementations§
Source§impl Particle
impl Particle
Sourcepub const fn new(kind: ParticleKind) -> Particle
pub const fn new(kind: ParticleKind) -> Particle
Creates a new Particle from kind.
§Examples
use use_particle::{Particle, ParticleKind};
let electron = Particle::new(ParticleKind::Electron);
assert_eq!(electron.kind, ParticleKind::Electron);Examples found in repository?
examples/facade_particle.rs (line 8)
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}Sourcepub const fn family(&self) -> ParticleFamily
pub const fn family(&self) -> ParticleFamily
Returns the particle family.
Examples found in repository?
examples/facade_particle.rs (line 10)
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}Sourcepub const fn charge(&self) -> ElementaryCharge
pub const fn charge(&self) -> ElementaryCharge
Returns the exact charge.
Examples found in repository?
examples/facade_particle.rs (line 17)
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}Sourcepub const fn statistics(&self) -> ParticleStatistics
pub const fn statistics(&self) -> ParticleStatistics
Returns the particle statistics.
Sourcepub const fn antiparticle(&self) -> Option<Particle>
pub const fn antiparticle(&self) -> Option<Particle>
Returns the antiparticle when it is modeled by this crate.
Sourcepub const fn rest_mass_mev_c2(&self) -> Option<f64>
pub const fn rest_mass_mev_c2(&self) -> Option<f64>
Returns the approximate rest mass in MeV/c^2.
Sourcepub const fn is_antiparticle(&self) -> bool
pub const fn is_antiparticle(&self) -> bool
Returns true when this particle is represented as an antiparticle variant.
Sourcepub const fn is_self_antiparticle(&self) -> bool
pub const fn is_self_antiparticle(&self) -> bool
Returns true when the particle is its own antiparticle.
Trait Implementations§
impl Copy for Particle
impl Eq for Particle
impl StructuralPartialEq for Particle
Auto Trait Implementations§
impl Freeze for Particle
impl RefUnwindSafe for Particle
impl Send for Particle
impl Sync for Particle
impl Unpin for Particle
impl UnsafeUnpin for Particle
impl UnwindSafe for Particle
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more