Skip to content

Commit

Permalink
Make angle helper constants available to no_std builds.
Browse files Browse the repository at this point in the history
  • Loading branch information
adamreichold committed Jul 20, 2020
1 parent cc4c66a commit 9187763
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
28 changes: 14 additions & 14 deletions src/si/angle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,37 +29,37 @@ quantity! {
}
}

#[cfg(all(feature = "std", feature = "f32"))]
#[cfg(feature = "f32")]
impl Angle<::si::SI<f32>, f32> {
/// A half turn, i.e. an angle with a value of π as measured in radians
pub const HALF_TURN: Self = Self {
dimension: std::marker::PhantomData,
units: std::marker::PhantomData,
value: std::f32::consts::PI,
dimension: ::lib::marker::PhantomData,
units: ::lib::marker::PhantomData,
value: ::lib::f32::consts::PI,
};

/// A full turn, i.e. an angle with a value of 2π as measured in radians
pub const FULL_TURN: Self = Self {
dimension: std::marker::PhantomData,
units: std::marker::PhantomData,
value: 2. * std::f32::consts::PI,
dimension: ::lib::marker::PhantomData,
units: ::lib::marker::PhantomData,
value: 2. * ::lib::f32::consts::PI,
};
}

#[cfg(all(feature = "std", feature = "f64"))]
#[cfg(feature = "f64")]
impl Angle<::si::SI<f64>, f64> {
/// A half turn, i.e. an angle with a value of π as measured in radians
pub const HALF_TURN: Self = Self {
dimension: std::marker::PhantomData,
units: std::marker::PhantomData,
value: std::f64::consts::PI,
dimension: ::lib::marker::PhantomData,
units: ::lib::marker::PhantomData,
value: ::lib::f64::consts::PI,
};

/// A full turn, i.e. an angle with a value of 2π as measured in radians
pub const FULL_TURN: Self = Self {
dimension: std::marker::PhantomData,
units: std::marker::PhantomData,
value: 2. * std::f64::consts::PI,
dimension: ::lib::marker::PhantomData,
units: ::lib::marker::PhantomData,
value: 2. * ::lib::f64::consts::PI,
};
}

Expand Down
16 changes: 8 additions & 8 deletions src/si/solid_angle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,25 @@ quantity! {
}
}

#[cfg(all(feature = "std", feature = "f32"))]
#[cfg(feature = "f32")]
impl SolidAngle<::si::SI<f32>, f32> {
/// The solid angle subtended by a sphere at its center, i.e. with a value 4π as measured in
/// steradians.
pub const SPHERE: Self = Self {
dimension: std::marker::PhantomData,
units: std::marker::PhantomData,
value: 4. * std::f32::consts::PI,
dimension: ::lib::marker::PhantomData,
units: ::lib::marker::PhantomData,
value: 4. * ::lib::f32::consts::PI,
};
}

#[cfg(all(feature = "std", feature = "f64"))]
#[cfg(feature = "f64")]
impl SolidAngle<::si::SI<f64>, f64> {
/// The solid angle subtended by a sphere at its center, i.e. with a value 4π as measured in
/// steradians.
pub const SPHERE: Self = Self {
dimension: std::marker::PhantomData,
units: std::marker::PhantomData,
value: 4. * std::f64::consts::PI,
dimension: ::lib::marker::PhantomData,
units: ::lib::marker::PhantomData,
value: 4. * ::lib::f64::consts::PI,
};
}

Expand Down

0 comments on commit 9187763

Please sign in to comment.