Skip to content

Commit

Permalink
Add num_traits proc_macro helper for explicit import
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jean-airoldie committed Nov 9, 2019
1 parent 1b361d7 commit 114944a
Show file tree
Hide file tree
Showing 5 changed files with 458 additions and 268 deletions.
2 changes: 2 additions & 0 deletions ci/test_full.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ echo Testing num-derive on rustc ${TRAVIS_RUST_VERSION}
# num-derive should build and test everywhere.
cargo build --verbose --features="$FEATURES"
cargo test --verbose --features="$FEATURES"
cd check; cargo test --verbose check; cd ..
cd import; cargo test --verbose import; cd ..
10 changes: 10 additions & 0 deletions import/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "import"
version = "0.0.1"
authors = ["jean-airoldie <[email protected]>"]
edition = "2018"
publish = false

[dependencies]
num-derive = { path = "../" }
num = { version = "0.2", default-features = false }
19 changes: 19 additions & 0 deletions import/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#[macro_use]
extern crate num_derive;

#[derive(
Debug,
Clone,
Copy,
PartialEq,
PartialOrd,
ToPrimitive,
FromPrimitive,
)]
#[num_traits = "num"]
#[repr(u8)]
enum Rgb {
Red = 0,
Green = 1,
Black = 2,
}
3 changes: 3 additions & 0 deletions import/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}
Loading

0 comments on commit 114944a

Please sign in to comment.