Skip to content

Commit

Permalink
Moved to format_ident
Browse files Browse the repository at this point in the history
  • Loading branch information
thatvertigo committed Dec 15, 2023
1 parent f6587d0 commit e03d470
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/target
.DS_Store
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
* Possible `#[marked]` attribute which creates a simple `Marker` type and field
* Should automatically be added when `.into` is called from base struct
* [ ] Bundled Resources
* [ ] Refactoring
* [ ] Use `quote_spanned` to ensure hygene

## Limitations
* You can't use `impl`s on `Bundled` types
Expand Down
12 changes: 4 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use heck::{AsPascalCase, AsSnakeCase};
use proc_macro::TokenStream;
use proc_macro2::Ident;
use quote::quote;
use quote::{format_ident, quote};
use syn::{parse_macro_input, Fields, FieldsNamed, Item};

#[proc_macro_derive(Bundled)]
Expand All @@ -12,17 +12,13 @@ pub fn bundle(input: TokenStream) -> TokenStream {
let ident = &st.ident;

// Identifier for generated internal module
let mod_ident = Ident::new(
&format!("_{}", AsSnakeCase(st.ident.to_string())),
st.ident.span(),
);
let mod_ident = format_ident!("_{}", AsSnakeCase(st.ident.to_string()).to_string());

// Identifier for component type (effectively type-level map)
let component_ident =
Ident::new(&format!("{}FieldComponent", st.ident), st.ident.span());
let component_ident = format_ident!("{}FieldComponent", st.ident);

// Identifier for generated bundle struct
let bundle_ident = Ident::new(&format!("{}Bundle", st.ident), st.ident.span());
let bundle_ident = format_ident!("{}Bundle", st.ident);

match st.fields {
Fields::Named(FieldsNamed {
Expand Down

0 comments on commit e03d470

Please sign in to comment.