-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(macros): prepare for adding other macros easily
- Loading branch information
1 parent
ad02804
commit 44e70e1
Showing
3 changed files
with
34 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
#![deny(clippy::pedantic)] | ||
|
||
mod utils; | ||
|
||
use proc_macro::TokenStream; | ||
|
||
include!("thread.rs"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
use quote::format_ident; | ||
|
||
const RIOT_RS_CRATE_NAME: &str = "riot-rs"; | ||
|
||
pub fn riot_rs_crate() -> syn::Ident { | ||
let riot_rs_crate = proc_macro_crate::crate_name(RIOT_RS_CRATE_NAME) | ||
.unwrap_or_else(|_| panic!("{RIOT_RS_CRATE_NAME} should be present in `Cargo.toml`")); | ||
|
||
match riot_rs_crate { | ||
proc_macro_crate::FoundCrate::Itself => { | ||
panic!( | ||
"{} cannot be used as a dependency of itself", | ||
env!("CARGO_CRATE_NAME"), | ||
); | ||
} | ||
proc_macro_crate::FoundCrate::Name(riot_rs_crate) => format_ident!("{}", riot_rs_crate), | ||
} | ||
} |