mirror of
https://github.com/italicsjenga/agb.git
synced 2025-02-23 22:58:18 +11:00
cargo fmt
This commit is contained in:
parent
9667e58e70
commit
be829e1d3d
1 changed files with 17 additions and 11 deletions
|
@ -3,8 +3,8 @@ use proc_macro::TokenStream;
|
||||||
|
|
||||||
use proc_macro2::Span;
|
use proc_macro2::Span;
|
||||||
use quote::quote;
|
use quote::quote;
|
||||||
use syn::{ItemFn, ReturnType, Type, Visibility, Ident};
|
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
|
use syn::{Ident, ItemFn, ReturnType, Type, Visibility};
|
||||||
|
|
||||||
#[proc_macro_attribute]
|
#[proc_macro_attribute]
|
||||||
pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream {
|
pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream {
|
||||||
|
@ -25,7 +25,10 @@ pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream {
|
||||||
"#[agb::entry] must have signature [unsafe] fn () -> !"
|
"#[agb::entry] must have signature [unsafe] fn () -> !"
|
||||||
);
|
);
|
||||||
|
|
||||||
assert!(args.to_string() == "", "Must pass no args to #[agb::entry] macro");
|
assert!(
|
||||||
|
args.to_string() == "",
|
||||||
|
"Must pass no args to #[agb::entry] macro"
|
||||||
|
);
|
||||||
|
|
||||||
let fn_name = random_ident();
|
let fn_name = random_ident();
|
||||||
|
|
||||||
|
@ -38,19 +41,22 @@ pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream {
|
||||||
pub fn #fn_name() -> ! {
|
pub fn #fn_name() -> ! {
|
||||||
#(#stmts)*
|
#(#stmts)*
|
||||||
}
|
}
|
||||||
).into()
|
)
|
||||||
|
.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn random_ident() -> Ident {
|
fn random_ident() -> Ident {
|
||||||
let mut rng = rand::thread_rng();
|
let mut rng = rand::thread_rng();
|
||||||
Ident::new(
|
Ident::new(
|
||||||
&(0..16).map(|i| {
|
&(0..16)
|
||||||
if i == 0 || rng.gen() {
|
.map(|i| {
|
||||||
(b'a' + rng.gen::<u8>() % 25) as char
|
if i == 0 || rng.gen() {
|
||||||
} else {
|
(b'a' + rng.gen::<u8>() % 25) as char
|
||||||
(b'0' + rng.gen::<u8>() % 10) as char
|
} else {
|
||||||
}
|
(b'0' + rng.gen::<u8>() % 10) as char
|
||||||
}).collect::<String>(),
|
}
|
||||||
Span::call_site()
|
})
|
||||||
|
.collect::<String>(),
|
||||||
|
Span::call_site(),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue