From ca86952c1486b7f2313fef62e6cacf36e248efd2 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sat, 13 Jul 2024 16:26:28 +0200 Subject: refactor: move & rename all mod.rs files --- macros/src/injectable.rs | 5 ++++ macros/src/injectable/mod.rs | 5 ---- macros/src/util.rs | 67 ++++++++++++++++++++++++++++++++++++++++++++ macros/src/util/mod.rs | 67 -------------------------------------------- 4 files changed, 72 insertions(+), 72 deletions(-) create mode 100644 macros/src/injectable.rs delete mode 100644 macros/src/injectable/mod.rs create mode 100644 macros/src/util.rs delete mode 100644 macros/src/util/mod.rs (limited to 'macros') diff --git a/macros/src/injectable.rs b/macros/src/injectable.rs new file mode 100644 index 0000000..0e6ddfd --- /dev/null +++ b/macros/src/injectable.rs @@ -0,0 +1,5 @@ +pub mod dependency; +pub mod dummy; +pub mod implementation; +pub mod macro_args; +pub mod named_attr_input; diff --git a/macros/src/injectable/mod.rs b/macros/src/injectable/mod.rs deleted file mode 100644 index 0e6ddfd..0000000 --- a/macros/src/injectable/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -pub mod dependency; -pub mod dummy; -pub mod implementation; -pub mod macro_args; -pub mod named_attr_input; diff --git a/macros/src/util.rs b/macros/src/util.rs new file mode 100644 index 0000000..3557896 --- /dev/null +++ b/macros/src/util.rs @@ -0,0 +1,67 @@ +pub mod error; +pub mod item_impl; +pub mod iterator_ext; +pub mod string; +pub mod syn_ext; +pub mod syn_path; +pub mod tokens; + +macro_rules! to_option { + ($($tokens: tt)+) => { + Some($($tokens)+) + }; + + () => { + None + }; +} + +macro_rules! or { + (($($tokens: tt)+) else ($($default: tt)*)) => { + $($tokens)* + }; + + (() else ($($default: tt)*)) => { + $($default)* + }; +} + +/// Imports the specified item, prepending 'Mock' to the item identifier if the `test` +/// configuration option is set. +/// +/// # Examples +/// ```ignore +/// use_double!(crate::dependency_history::DependencyHistory); +/// ``` +///
+/// +/// Expands to the following when `cfg(not(test))` +/// ```ignore +/// use crate::dependency_history::DependencyHistory; +/// ``` +///
+/// +/// Expands to the following when `cfg(test)` +/// ```ignore +/// use crate::dependency_history::MockDependencyHistory as DependencyHistory; +/// ``` +macro_rules! use_double { + ($([$($part: ident),*])? $item_path_part: ident :: $($next_part: tt)+) => { + use_double!( + [$($($part,)*)? $item_path_part] + $($next_part)+ + ); + }; + + ([$($part: ident),*] $item_path_part: ident) => { + #[cfg(not(test))] + use $($part::)* $item_path_part; + + ::paste::paste! { + #[cfg(test)] + use $($part::)* [] as $item_path_part; + } + }; +} + +pub(crate) use {or, to_option, use_double}; diff --git a/macros/src/util/mod.rs b/macros/src/util/mod.rs deleted file mode 100644 index 3557896..0000000 --- a/macros/src/util/mod.rs +++ /dev/null @@ -1,67 +0,0 @@ -pub mod error; -pub mod item_impl; -pub mod iterator_ext; -pub mod string; -pub mod syn_ext; -pub mod syn_path; -pub mod tokens; - -macro_rules! to_option { - ($($tokens: tt)+) => { - Some($($tokens)+) - }; - - () => { - None - }; -} - -macro_rules! or { - (($($tokens: tt)+) else ($($default: tt)*)) => { - $($tokens)* - }; - - (() else ($($default: tt)*)) => { - $($default)* - }; -} - -/// Imports the specified item, prepending 'Mock' to the item identifier if the `test` -/// configuration option is set. -/// -/// # Examples -/// ```ignore -/// use_double!(crate::dependency_history::DependencyHistory); -/// ``` -///
-/// -/// Expands to the following when `cfg(not(test))` -/// ```ignore -/// use crate::dependency_history::DependencyHistory; -/// ``` -///
-/// -/// Expands to the following when `cfg(test)` -/// ```ignore -/// use crate::dependency_history::MockDependencyHistory as DependencyHistory; -/// ``` -macro_rules! use_double { - ($([$($part: ident),*])? $item_path_part: ident :: $($next_part: tt)+) => { - use_double!( - [$($($part,)*)? $item_path_part] - $($next_part)+ - ); - }; - - ([$($part: ident),*] $item_path_part: ident) => { - #[cfg(not(test))] - use $($part::)* $item_path_part; - - ::paste::paste! { - #[cfg(test)] - use $($part::)* [] as $item_path_part; - } - }; -} - -pub(crate) use {or, to_option, use_double}; -- cgit v1.2.3-18-g5258