Skip to content

Commit

Permalink
Correct uom feature hygiene in macro generated code.
Browse files Browse the repository at this point in the history
Add macros to condtionally include contents based on features `uom` was
compiled with rather then features in the destination crate. Resolves
#98 and #100.
  • Loading branch information
iliekturtles committed Aug 28, 2018
1 parent a843283 commit 73075f4
Show file tree
Hide file tree
Showing 4 changed files with 182 additions and 43 deletions.
83 changes: 83 additions & 0 deletions src/features.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#[macro_export]
#[cfg(feature = "autoconvert")]
macro_rules! autoconvert {
($($tt:tt)*) => { $($tt)* };
}

#[macro_export]
#[cfg(not(feature = "autoconvert"))]
macro_rules! autoconvert {
($($tt:tt)*) => {};
}

#[macro_export]
#[cfg(any(feature = "autoconvert", test))]
macro_rules! autoconvert_test {
($($tt:tt)*) => { $($tt)* };
}

#[macro_export]
#[cfg(not(any(feature = "autoconvert", test)))]
macro_rules! autoconvert_test {
($($tt:tt)*) => {};
}

#[macro_export]
#[cfg(feature = "autoconvert")]
macro_rules! not_autoconvert {
($($tt:tt)*) => {};
}

#[macro_export]
#[cfg(not(feature = "autoconvert"))]
macro_rules! not_autoconvert {
($($tt:tt)*) => { $($tt)* };
}

#[macro_export]
#[cfg(feature = "serde")]
macro_rules! serde {
($($tt:tt)*) => { $($tt)* };
}

#[macro_export]
#[cfg(not(feature = "serde"))]
macro_rules! serde {
($($tt:tt)*) => {};
}

#[macro_export]
#[cfg(feature = "si")]
macro_rules! si {
($($tt:tt)*) => { $($tt)* };
}

#[macro_export]
#[cfg(not(feature = "si"))]
macro_rules! si {
($($tt:tt)*) => {};
}

#[macro_export]
#[cfg(feature = "std")]
macro_rules! std {
($($tt:tt)*) => { $($tt)* };
}

#[macro_export]
#[cfg(not(feature = "std"))]
macro_rules! std {
($($tt:tt)*) => {};
}

#[macro_export]
#[cfg(test)]
macro_rules! test {
($($tt:tt)*) => { $($tt)* };
}

#[macro_export]
#[cfg(not(test))]
macro_rules! test {
($($tt:tt)*) => {};
}
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ pub mod num {
}
}

#[macro_use]
mod features;

#[macro_use]
mod storage_types;

Expand Down
Loading

0 comments on commit 73075f4

Please sign in to comment.