Skip to content

Commit

Permalink
feat!: change LdtkEntity's #[with] attribute to borrow EntityInstance (
Browse files Browse the repository at this point in the history
…#158)

fix!: pass EntityInstance as ref to with function instead of cloning
  • Loading branch information
geieredgar committed Feb 8, 2023
1 parent d3fbd3c commit c052b31
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion macros/src/ldtk_entity.rs
Expand Up @@ -340,7 +340,7 @@ fn expand_with_attribute(
match nested.first().unwrap() {
syn::NestedMeta::Meta(syn::Meta::Path(path)) => {
quote! {
#field_name: #path(entity_instance.clone()),
#field_name: #path(entity_instance),
}
}
_ => panic!("Expected function as the only argument of #[with(...)]"),
Expand Down
4 changes: 2 additions & 2 deletions src/app/ldtk_entity.rs
Expand Up @@ -252,7 +252,7 @@ use std::{collections::HashMap, marker::PhantomData};
/// Indicates that this component or bundle should be initialized with the given
/// function.
///
/// Note: The given function should have signature `fn (entity: EntityInstance) -> T`
/// Note: The given function should have signature `fn (entity: &EntityInstance) -> T`
/// where `T` is the field type. The function should also be accessible in the scope.
///
/// ```
Expand All @@ -275,7 +275,7 @@ use std::{collections::HashMap, marker::PhantomData};
/// collider: InventoryBundle,
/// }
///
/// fn player_initial_inventory(_: EntityInstance) -> InventoryBundle {
/// fn player_initial_inventory(_: &EntityInstance) -> InventoryBundle {
/// InventoryBundle {
/// money: Money(4.0)
/// }
Expand Down

0 comments on commit c052b31

Please sign in to comment.