Skip to content

Commit

Permalink
Merge #56
Browse files Browse the repository at this point in the history
56: Make Float work with no_std (rebased #50) r=cuviper a=cuviper

- Use ::core::num::FpCategory when deriving Float to work with no_std
- Get rid of unnecessary double-borrowing to fix clippy lint


Co-authored-by: vkahl <42325420+vkahl@users.noreply.github.com>
Co-authored-by: Valentin Kahl <code@valentin-kahl.de>
  • Loading branch information
3 people authored Jul 5, 2023
2 parents fce481d + aef0b5e commit 58dad2c
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ impl NumTraits {
if self.explicit {
output
} else {
dummy_const_trick(trait_, &name, output)
dummy_const_trick(trait_, name, output)
}
}
}
Expand Down Expand Up @@ -369,7 +369,7 @@ pub fn from_primitive(input: TokenStream) -> TokenStream {
}
};

import.wrap("FromPrimitive", &name, impl_).into()
import.wrap("FromPrimitive", name, impl_).into()
}

/// Derives [`num_traits::ToPrimitive`][to] for simple enums and newtypes.
Expand Down Expand Up @@ -544,7 +544,7 @@ pub fn to_primitive(input: TokenStream) -> TokenStream {
}
};

import.wrap("ToPrimitive", &name, impl_).into()
import.wrap("ToPrimitive", name, impl_).into()
}

const NEWTYPE_ONLY: &str = "This trait can only be derived for newtypes";
Expand Down Expand Up @@ -623,7 +623,7 @@ pub fn num_cast(input: TokenStream) -> TokenStream {
}
};

import.wrap("NumCast", &name, impl_).into()
import.wrap("NumCast", name, impl_).into()
}

/// Derives [`num_traits::Zero`][zero] for newtypes. The inner type must already implement `Zero`.
Expand All @@ -650,7 +650,7 @@ pub fn zero(input: TokenStream) -> TokenStream {
}
};

import.wrap("Zero", &name, impl_).into()
import.wrap("Zero", name, impl_).into()
}

/// Derives [`num_traits::One`][one] for newtypes. The inner type must already implement `One`.
Expand All @@ -677,7 +677,7 @@ pub fn one(input: TokenStream) -> TokenStream {
}
};

import.wrap("One", &name, impl_).into()
import.wrap("One", name, impl_).into()
}

/// Derives [`num_traits::Num`][num] for newtypes. The inner type must already implement `Num`.
Expand All @@ -701,7 +701,7 @@ pub fn num(input: TokenStream) -> TokenStream {
}
};

import.wrap("Num", &name, impl_).into()
import.wrap("Num", name, impl_).into()
}

/// Derives [`num_traits::Float`][float] for newtypes. The inner type must already implement
Expand Down Expand Up @@ -763,7 +763,7 @@ pub fn float(input: TokenStream) -> TokenStream {
<#inner_ty as #import::Float>::is_normal(self.0)
}
#[inline]
fn classify(self) -> ::std::num::FpCategory {
fn classify(self) -> ::core::num::FpCategory {
<#inner_ty as #import::Float>::classify(self.0)
}
#[inline]
Expand Down Expand Up @@ -950,5 +950,5 @@ pub fn float(input: TokenStream) -> TokenStream {
}
};

import.wrap("Float", &name, impl_).into()
import.wrap("Float", name, impl_).into()
}

0 comments on commit 58dad2c

Please sign in to comment.