num-derive
num-derive copied to clipboard
Procedural macros to derive numeric traits in Rust
```rust #[derive(Float)] struct A(T); ``` Here, [`float`](https://docs.rs/num-derive/0.2.3/src/num_derive/lib.rs.html#607-792) will try to implement Float for `T`, but `T` is a parameter. Instead, it should: ```rust impl Float for A{...} ```
If I have ```rust enum Foo { FooA = 3, FooB = 7, OtherFoo(u8), } ``` it would be nice to have some way to specify that: ```rust Foo::from_u8(3) ==...
I'm trying to use num_derive, but the way I got it working doesn't align to the documentation. Enum definition: https://github.com/ruckc/mcr/blob/num_derive/src/igmp/types.rs#L4 Seemingly required use: https://github.com/ruckc/mcr/blob/num_derive/src/igmp/header.rs#L3 For some reason in the files...
I would like to be able to derive the traits for CheckedAdd, CheckedSub, and the other checked arithmetic for structs whose members implement those traits. A simple solution would be...
_From @gnzlbg on October 26, 2017 9:18_ Say I want to implement some num traits for: ```rust struct R64(f64); ``` Is there a macro in `num_derive` to do this? Currently...
I'm using `bindgen` to create a enum, here is the generated code. ```rust #[repr(u32)] #[non_exhaustive] #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, FromPrimitive)] pub enum Code { kSuccess = 0, kFailed...
It would be nice if [`num::Bounded`](https://docs.rs/num/latest/num/trait.Bounded.html) can be derived for a newtype for a numerical value. (There may be some other traits for which derive macro is worth implementing.)