Skip to content

Commit

Permalink
Remove to_str() calls added in c532a3d
Browse files Browse the repository at this point in the history
It doesn't look like they are needed
  • Loading branch information
BaxHugh authored and omid committed Apr 4, 2024
1 parent 7dbea94 commit ca667de
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
8 changes: 4 additions & 4 deletions cached_proc_macro/src/cached.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ pub fn cached(args: TokenStream, input: TokenStream) -> TokenStream {

// make the cache identifier
let cache_ident = match args.name {
Some(ref name) => Ident::new(name.as_str(), fn_ident.span()),
Some(ref name) => Ident::new(name, fn_ident.span()),
None => Ident::new(&fn_ident.to_string().to_uppercase(), fn_ident.span()),
};

Expand Down Expand Up @@ -131,10 +131,10 @@ pub fn cached(args: TokenStream, input: TokenStream) -> TokenStream {
(cache_ty, cache_create)
}
(false, None, None, Some(type_str), Some(create_str), _) => {
let ty = parse_str::<Type>(type_str.as_str()).expect("unable to parse cache type");
let ty = parse_str::<Type>(type_str).expect("unable to parse cache type");

let cache_create = parse_str::<Block>(create_str.as_str())
.expect("unable to parse cache create block");
let cache_create =
parse_str::<Block>(create_str).expect("unable to parse cache create block");

(quote! { #ty }, quote! { #cache_create })
}
Expand Down
11 changes: 5 additions & 6 deletions cached_proc_macro/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,16 @@ pub(super) fn make_cache_key_type(
) -> (TokenStream2, TokenStream2) {
match (key, convert, ty) {
(Some(key_str), Some(convert_str), _) => {
let cache_key_ty =
parse_str::<Type>(key_str.as_str()).expect("unable to parse cache key type");
let cache_key_ty = parse_str::<Type>(key_str).expect("unable to parse cache key type");

let key_convert_block = parse_str::<Block>(convert_str.as_str())
.expect("unable to parse key convert block");
let key_convert_block =
parse_str::<Block>(convert_str).expect("unable to parse key convert block");

(quote! {#cache_key_ty}, quote! {#key_convert_block})
}
(None, Some(convert_str), Some(_)) => {
let key_convert_block = parse_str::<Block>(convert_str.as_str())
.expect("unable to parse key convert block");
let key_convert_block =
parse_str::<Block>(convert_str).expect("unable to parse key convert block");

(quote! {}, quote! {#key_convert_block})
}
Expand Down

0 comments on commit ca667de

Please sign in to comment.