Skip to content

Commit ba73ba2

Browse files
committed
Avoid infinite recursion on no_std
1 parent b7d2a99 commit ba73ba2

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

traits/src/float.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1268,16 +1268,30 @@ macro_rules! float_impl {
12681268
<$T>::log10(self)
12691269
}
12701270

1271+
#[cfg(feature = "std")]
12711272
#[inline]
12721273
fn to_degrees(self) -> Self {
12731274
<$T>::to_degrees(self)
12741275
}
12751276

1277+
#[cfg(feature = "std")]
12761278
#[inline]
12771279
fn to_radians(self) -> Self {
12781280
<$T>::to_radians(self)
12791281
}
12801282

1283+
#[cfg(not(feature = "std"))]
1284+
#[inline]
1285+
fn to_degrees(self) -> Self {
1286+
self * (180. / ::core::$T::consts::PI)
1287+
}
1288+
1289+
#[cfg(not(feature = "std"))]
1290+
#[inline]
1291+
fn to_radians(self) -> Self {
1292+
self * (::core::$T::consts::PI / 180.)
1293+
}
1294+
12811295
#[cfg(feature = "std")]
12821296
#[inline]
12831297
fn max(self, other: Self) -> Self {

traits/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
html_root_url = "https://rust-num.github.io/num/",
1515
html_playground_url = "http://play.integer32.com/")]
1616

17+
#![deny(unconditional_recursion)]
18+
1719
#![cfg_attr(not(feature = "std"), no_std)]
1820
#[cfg(feature = "std")]
1921
extern crate core;

0 commit comments

Comments
 (0)