Skip to content

Commit 1d02445

Browse files
committed
Add num-traits to Cargo.toml
The `num-derive` requires `num-traits` to be explicitly included in Cargo.toml. (cf. rust-num/num-derive#34) This issue may be fixed in rust-num/num-derive#35.
1 parent a1e2a76 commit 1d02445

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

Cargo.lock

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ default = ["jemalloc"]
1919
# 多バイト長整数、分数、複素数など
2020
num = "=0.2.0"
2121
num-derive = "=0.3.0"
22+
# num-derive が依存するため必要
23+
num-traits = "=0.2.9"
2224

2325
# 多次元配列
2426
ndarray = "=0.13.0"

tests/test_num_derive.rs

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
use num_derive::{FromPrimitive, Num, NumCast, NumOps, One, ToPrimitive, Zero};
2+
3+
#[derive(
4+
Debug,
5+
Eq,
6+
PartialEq,
7+
PartialOrd,
8+
Ord,
9+
FromPrimitive,
10+
ToPrimitive,
11+
One,
12+
Zero,
13+
Num,
14+
NumCast,
15+
NumOps,
16+
)]
17+
struct Weight(i32);
18+
19+
fn main() {
20+
let w1 = Weight(3);
21+
let w2 = Weight(4);
22+
println!("{:?}", w1 + w2); // => "Weight(7)"
23+
}

0 commit comments

Comments
 (0)