Skip to content

Commit

Permalink
[clean] remove proc-macro
Browse files Browse the repository at this point in the history
  • Loading branch information
fuyu0425 committed Nov 21, 2022
1 parent 5565ecb commit 60ba58e
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 34 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/target
/archive
2 changes: 0 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ authors = ["Yu-Fu Fu <[email protected]>"]
description = "CLI for FastMail MaskedEmail"

[lib]
proc-macro = true

# [[bin]]
# name = "maskedemail"
Expand All @@ -27,13 +26,11 @@ futures = "0.3.25"
itertools = "0.10.5"
log = "0.4.17"
once_cell = "1.16.0"
quote = "1.0.21"
reqwest = { version = "0.11.13", features = ["blocking", "json"] }
serde = { version = "1.0.147", features = ["derive"] }
serde_json = "1.0.88"
serde_tuple = "0.5.0"
shadow-rs = "0.17.1"
syn = "1.0.103"
tokio = { version = "1.22.0", features = ["full"] }
tracing = "0.1"
tracing-subscriber = { version = "0.3.16", features = ["env-filter"] }
Expand Down
23 changes: 0 additions & 23 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1 @@
extern crate proc_macro;

use proc_macro::TokenStream;
use quote::quote;
use syn::{parse_macro_input, ItemFn};

#[proc_macro_attribute]
pub fn with_client(_args: TokenStream, stream: TokenStream) -> TokenStream {
let input = parse_macro_input!(stream as ItemFn);
let ItemFn {
attrs,
vis,
sig,
block,
} = input;
let stmts = &block.stmts;
let ret = quote! {
#(#attrs)* #vis #sig {
let client = get_client();
#(#stmts)*
}
};
ret.into()
}
6 changes: 0 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@ fn get_api_token() -> &'static String {
&CONFIG.get().unwrap().api_token
}

static CLIENT: OnceCell<reqwest::Client> = OnceCell::new();

fn get_client() -> &'static reqwest::Client {
&CLIENT.get().unwrap()
}

#[derive(Parser, Debug)]
#[clap(author, version, about)]
pub struct Args {
Expand Down

0 comments on commit 60ba58e

Please sign in to comment.