Añade nueva macro module_name!()
Devuelve el nombre del módulo actual en el que se ejecuta la macro.
This commit is contained in:
parent
993d6fc0eb
commit
d37b2e09ab
3 changed files with 13 additions and 0 deletions
|
|
@ -11,6 +11,7 @@ pub mod entity {
|
||||||
|
|
||||||
pub mod migration {
|
pub mod migration {
|
||||||
pub use sea_schema::migration::prelude::*;
|
pub use sea_schema::migration::prelude::*;
|
||||||
|
pub use crate::module_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
pub use crate::{
|
pub use crate::{
|
||||||
args,
|
args,
|
||||||
concat_string,
|
concat_string,
|
||||||
|
module_name,
|
||||||
theme_static_files,
|
theme_static_files,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,17 @@ macro_rules! args {
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! module_name {
|
||||||
|
() => {{
|
||||||
|
let name = module_path!();
|
||||||
|
match name.rfind("::") {
|
||||||
|
Some(position) => &name[(position + 2)..],
|
||||||
|
None => name
|
||||||
|
}
|
||||||
|
}};
|
||||||
|
}
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! theme_static_files {
|
macro_rules! theme_static_files {
|
||||||
( $cfg:ident, $dir:expr ) => {{
|
( $cfg:ident, $dir:expr ) => {{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue