Skip to content

Commit 23fb958

Browse files
committed
Removed the Struct stuff,, just the Dynamic Struct removal methods now
1 parent 20e6765 commit 23fb958

File tree

6 files changed

+59
-130
lines changed

6 files changed

+59
-130
lines changed

crates/bevy_ecs/src/reflect/bundle.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ impl<B: Bundle + Reflect + TypePath + BundleFromComponents> FromType<B> for Refl
166166
match reflected_bundle.reflect_ref() {
167167
ReflectRef::Struct(bundle) => bundle
168168
.iter_fields()
169-
.for_each(|(_, field)| apply_field(&mut entity, field, registry)),
169+
.for_each(|field| apply_field(&mut entity, field, registry)),
170170
ReflectRef::Tuple(bundle) => bundle
171171
.iter_fields()
172172
.for_each(|field| apply_field(&mut entity, field, registry)),
@@ -195,17 +195,15 @@ impl<B: Bundle + Reflect + TypePath + BundleFromComponents> FromType<B> for Refl
195195
);
196196
} else {
197197
match reflected_bundle.reflect_ref() {
198-
ReflectRef::Struct(bundle) => {
199-
bundle.iter_fields().for_each(|(_, field)| {
200-
apply_or_insert_field_mapped(
201-
entity,
202-
field,
203-
registry,
204-
mapper,
205-
relationship_hook_mode,
206-
);
207-
});
208-
}
198+
ReflectRef::Struct(bundle) => bundle.iter_fields().for_each(|field| {
199+
apply_or_insert_field_mapped(
200+
entity,
201+
field,
202+
registry,
203+
mapper,
204+
relationship_hook_mode,
205+
);
206+
}),
209207
ReflectRef::Tuple(bundle) => bundle.iter_fields().for_each(|field| {
210208
apply_or_insert_field_mapped(
211209
entity,

crates/bevy_reflect/derive/src/impls/structs.rs

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -115,23 +115,6 @@ pub(crate) fn impl_struct(reflect_struct: &ReflectStruct) -> proc_macro2::TokenS
115115
}
116116
}
117117

118-
fn name_of(&self, field: &dyn #bevy_reflect_path::PartialReflect) -> #FQOption<&str> {
119-
#(if ::core::ptr::addr_eq(#fields_ref, field) { return #fqoption::Some(#field_names) })*
120-
#FQOption::None
121-
}
122-
123-
fn index_of(&self, field: &dyn #bevy_reflect_path::PartialReflect) -> #FQOption<usize> {
124-
#(if ::core::ptr::addr_eq(#fields_ref, field) { return #fqoption::Some(#field_indices) })*
125-
#FQOption::None
126-
}
127-
128-
fn index_of_name(&self, name: &str) -> #FQOption<usize> {
129-
match name {
130-
#(#field_names => #fqoption::Some(#field_indices),)*
131-
_ => #FQOption::None,
132-
}
133-
}
134-
135118
fn field_len(&self) -> usize {
136119
#field_count
137120
}
@@ -161,7 +144,8 @@ pub(crate) fn impl_struct(reflect_struct: &ReflectStruct) -> proc_macro2::TokenS
161144
) -> #FQResult<(), #bevy_reflect_path::ApplyError> {
162145
if let #bevy_reflect_path::ReflectRef::Struct(struct_value)
163146
= #bevy_reflect_path::PartialReflect::reflect_ref(value) {
164-
for (name, value) in #bevy_reflect_path::structs::Struct::iter_fields(struct_value) {
147+
for (i, value) in ::core::iter::Iterator::enumerate(#bevy_reflect_path::structs::Struct::iter_fields(struct_value)) {
148+
let name = #bevy_reflect_path::structs::Struct::name_at(struct_value, i).unwrap();
165149
if let #FQOption::Some(v) = #bevy_reflect_path::structs::Struct::field_mut(self, name) {
166150
#bevy_reflect_path::PartialReflect::try_apply(v, value)?;
167151
}

crates/bevy_reflect/src/enums/dynamic_enum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ impl Enum for DynamicEnum {
246246

247247
fn index_of(&self, name: &str) -> Option<usize> {
248248
if let DynamicVariant::Struct(data) = &self.variant {
249-
data.index_of_name(name)
249+
data.index_of(name)
250250
} else {
251251
None
252252
}

crates/bevy_reflect/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1117,7 +1117,7 @@ mod tests {
11171117

11181118
let values: Vec<u32> = foo
11191119
.iter_fields()
1120-
.map(|(_, value)| *value.try_downcast_ref::<u32>().unwrap())
1120+
.map(|value| *value.try_downcast_ref::<u32>().unwrap())
11211121
.collect();
11221122
assert_eq!(values, vec![1]);
11231123
}

crates/bevy_reflect/src/serde/ser/structs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl<P: ReflectSerializerProcessor> Serialize for StructSerializer<'_, P> {
4848
self.struct_value.field_len() - ignored_len,
4949
)?;
5050

51-
for (index, (_, value)) in self.struct_value.iter_fields().enumerate() {
51+
for (index, value) in self.struct_value.iter_fields().enumerate() {
5252
if serialization_data.is_some_and(|data| data.is_field_skipped(index)) {
5353
continue;
5454
}

0 commit comments

Comments
 (0)