Skip to content

Commit 1da2450

Browse files
jean-airoldiecuviper
authored andcommitted
Add num_traits proc_macro helper for explicit import
This allows the user to specify a identifier for the `num_traits` crate so that the proc_macro can directly depend in it. This is usefull when reexporting `num-derive` and using `num-trait` as a transitive import. Fixes #34.
1 parent bafa54c commit 1da2450

File tree

5 files changed

+459
-268
lines changed

5 files changed

+459
-268
lines changed

ci/test_full.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,6 @@ done
4545
# test all supported features
4646
cargo build --features="${FEATURES[*]}"
4747
cargo test --features="${FEATURES[*]}"
48+
49+
cd check; cargo test --verbose check; cd ..
50+
cd import; cargo test --verbose import; cd ..

import/Cargo.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[package]
2+
name = "import"
3+
version = "0.0.1"
4+
authors = ["jean-airoldie <25088801+jean-airoldie@users.noreply.github.com>"]
5+
edition = "2018"
6+
publish = false
7+
8+
[dependencies]
9+
num-derive = { path = "../" }
10+
num = { version = "0.2", default-features = false }

import/src/lib.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#[macro_use]
2+
extern crate num_derive;
3+
4+
#[derive(
5+
Debug,
6+
Clone,
7+
Copy,
8+
PartialEq,
9+
PartialOrd,
10+
ToPrimitive,
11+
FromPrimitive,
12+
)]
13+
#[num_traits = "num"]
14+
#[repr(u8)]
15+
enum Rgb {
16+
Red = 0,
17+
Green = 1,
18+
Black = 2,
19+
}

import/src/main.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
println!("Hello, world!");
3+
}

0 commit comments

Comments
 (0)