Skip to content

Commit 27bed7c

Browse files
committed
Move array-like exports to bevy_reflect::array
1 parent e4eb916 commit 27bed7c

File tree

11 files changed

+31
-25
lines changed

11 files changed

+31
-25
lines changed

crates/bevy_reflect/src/array.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
//! Traits and types used to power [array-like] operations via reflection.
2+
//!
3+
//! [array-like]: https://doc.rust-lang.org/book/ch03-02-data-types.html#the-array-type
14
use crate::generics::impl_generic_info_methods;
25
use crate::{
36
type_info::impl_type_methods, utility::reflect_hasher, ApplyError, Generics, MaybeTyped,
@@ -31,7 +34,7 @@ use core::{
3134
/// # Example
3235
///
3336
/// ```
34-
/// use bevy_reflect::{PartialReflect, Array};
37+
/// use bevy_reflect::{PartialReflect, array::Array};
3538
///
3639
/// let foo: &dyn Array = &[123_u32, 456_u32, 789_u32];
3740
/// assert_eq!(foo.len(), 3);

crates/bevy_reflect/src/impls/core/primitives.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,21 +376,21 @@ impl<T: Reflect + MaybeTyped + TypePath + GetTypeRegistration, const N: usize> P
376376

377377
#[inline]
378378
fn reflect_hash(&self) -> Option<u64> {
379-
crate::array_hash(self)
379+
crate::array::array_hash(self)
380380
}
381381

382382
#[inline]
383383
fn reflect_partial_eq(&self, value: &dyn PartialReflect) -> Option<bool> {
384-
crate::array_partial_eq(self, value)
384+
crate::array::array_partial_eq(self, value)
385385
}
386386

387387
fn apply(&mut self, value: &dyn PartialReflect) {
388-
crate::array_apply(self, value);
388+
crate::array::array_apply(self, value);
389389
}
390390

391391
#[inline]
392392
fn try_apply(&mut self, value: &dyn PartialReflect) -> Result<(), ApplyError> {
393-
crate::array_try_apply(self, value)
393+
crate::array::array_try_apply(self, value)
394394
}
395395
}
396396

crates/bevy_reflect/src/kind.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use thiserror::Error;
33

44
#[cfg(feature = "functions")]
55
use crate::func::Function;
6-
use crate::{Array, Enum, List, Map, PartialReflect, Set, Struct, Tuple, TupleStruct};
6+
use crate::{array::Array, Enum, List, Map, PartialReflect, Set, Struct, Tuple, TupleStruct};
77

88
/// An enumeration of the "kinds" of a reflected type.
99
///

crates/bevy_reflect/src/lib.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,9 @@
541541
//! [the language feature for dyn upcasting coercion]: https://github.com/rust-lang/rust/issues/65991
542542
//! [derive macro]: derive@crate::Reflect
543543
//! [`'static` lifetime]: https://doc.rust-lang.org/rust-by-example/scope/lifetime/static_lifetime.html#trait-bound
544+
//! [`Array`]: crate::array::Array
544545
//! [`Function`]: crate::func::Function
546+
//! [`DynamicArray`]: crate::array::DynamicArray
545547
//! [derive macro documentation]: derive@crate::Reflect
546548
//! [deriving `Reflect`]: derive@crate::Reflect
547549
//! [type data]: TypeData
@@ -578,7 +580,7 @@ extern crate alloc;
578580
// Required to make proc macros work in bevy itself.
579581
extern crate self as bevy_reflect;
580582

581-
mod array;
583+
pub mod array;
582584
mod error;
583585
mod fields;
584586
mod from_reflect;
@@ -653,7 +655,6 @@ pub mod prelude {
653655
pub use crate::func::{Function, IntoFunction, IntoFunctionMut};
654656
}
655657

656-
pub use array::*;
657658
pub use enums::*;
658659
pub use error::*;
659660
pub use fields::*;
@@ -684,7 +685,7 @@ pub use erased_serde;
684685
#[doc(hidden)]
685686
pub mod __macro_exports {
686687
use crate::{
687-
DynamicArray, DynamicEnum, DynamicList, DynamicMap, DynamicStruct, DynamicTuple,
688+
array::DynamicArray, DynamicEnum, DynamicList, DynamicMap, DynamicStruct, DynamicTuple,
688689
DynamicTupleStruct, GetTypeRegistration, TypeRegistry,
689690
};
690691

@@ -864,7 +865,7 @@ mod tests {
864865
};
865866
use static_assertions::{assert_impl_all, assert_not_impl_all};
866867

867-
use super::{prelude::*, *};
868+
use super::{array::*, prelude::*, *};
868869
use crate::{
869870
serde::{ReflectDeserializer, ReflectSerializer},
870871
utility::GenericTypePathCell,

crates/bevy_reflect/src/list.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use crate::{
1919
/// This corresponds to types, like [`Vec`], which contain an ordered sequence
2020
/// of elements that implement [`Reflect`].
2121
///
22-
/// Unlike the [`Array`](crate::Array) trait, implementors of this trait are not expected to
22+
/// Unlike the [`Array`](crate::array::Array) trait, implementors of this trait are not expected to
2323
/// maintain a constant length.
2424
/// Methods like [insertion](List::insert) and [removal](List::remove) explicitly allow for their
2525
/// internal size to change.

crates/bevy_reflect/src/path/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ impl<'a> ReflectPath<'a> for &'a str {
242242
/// [`Tuple`]: crate::Tuple
243243
/// [`TupleStruct`]: crate::TupleStruct
244244
/// [`List`]: crate::List
245-
/// [`Array`]: crate::Array
245+
/// [`Array`]: crate::array::Array
246246
/// [`Enum`]: crate::Enum
247247
#[diagnostic::on_unimplemented(
248248
message = "`{Self}` does not implement `GetPath` so cannot be accessed by reflection path",

crates/bevy_reflect/src/reflect.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::{
2-
array_debug, enum_debug, list_debug, map_debug, set_debug, struct_debug, tuple_debug,
2+
array::array_debug, enum_debug, list_debug, map_debug, set_debug, struct_debug, tuple_debug,
33
tuple_struct_debug, DynamicTypePath, DynamicTyped, OpaqueInfo, ReflectCloneError, ReflectKind,
44
ReflectKindMismatchError, ReflectMut, ReflectOwned, ReflectRef, TypeInfo, TypePath, Typed,
55
};
@@ -48,7 +48,7 @@ pub enum ApplyError {
4848
#[error("attempted to apply type with {from_size} size to a type with {to_size} size")]
4949
/// Attempted to apply an [array-like] type to another of different size, e.g. a [u8; 4] to [u8; 3].
5050
///
51-
/// [array-like]: crate::Array
51+
/// [array-like]: crate::array::Array
5252
DifferentSize {
5353
/// Size of the value we attempted to apply, in elements.
5454
from_size: usize,
@@ -186,7 +186,7 @@ where
186186
/// [`Tuple`]: crate::Tuple
187187
/// [`Enum`]: crate::Enum
188188
/// [`List`]: crate::List
189-
/// [`Array`]: crate::Array
189+
/// [`Array`]: crate::array::Array
190190
/// [`Map`]: crate::Map
191191
/// [`Set`]: crate::Set
192192
/// [`list_apply`]: crate::list_apply

crates/bevy_reflect/src/serde/de/arrays.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::{
2+
array::{ArrayInfo, DynamicArray},
23
serde::{de::registration_utils::try_get_registration, TypedReflectDeserializer},
3-
ArrayInfo, DynamicArray, TypeRegistry,
4+
TypeRegistry,
45
};
56
use alloc::{string::ToString, vec::Vec};
67
use core::{fmt, fmt::Formatter};

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{serde::TypedReflectSerializer, Array, TypeRegistry};
1+
use crate::{array::Array, serde::TypedReflectSerializer, TypeRegistry};
22
use serde::{ser::SerializeTuple, Serialize};
33

44
use super::ReflectSerializerProcessor;

crates/bevy_reflect/src/type_info.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
use crate::{
2-
ArrayInfo, DynamicArray, DynamicEnum, DynamicList, DynamicMap, DynamicStruct, DynamicTuple,
3-
DynamicTupleStruct, EnumInfo, Generics, ListInfo, MapInfo, PartialReflect, Reflect,
4-
ReflectKind, SetInfo, StructInfo, TupleInfo, TupleStructInfo, TypePath, TypePathTable,
2+
array::{ArrayInfo, DynamicArray},
3+
DynamicEnum, DynamicList, DynamicMap, DynamicStruct, DynamicTuple, DynamicTupleStruct,
4+
EnumInfo, Generics, ListInfo, MapInfo, PartialReflect, Reflect, ReflectKind, SetInfo,
5+
StructInfo, TupleInfo, TupleStructInfo, TypePath, TypePathTable,
56
};
67
use core::{
78
any::{Any, TypeId},
@@ -219,7 +220,7 @@ pub enum TypeInfo {
219220
List(ListInfo),
220221
/// Type information for an [array-like] type.
221222
///
222-
/// [array-like]: crate::Array
223+
/// [array-like]: crate::array::Array
223224
Array(ArrayInfo),
224225
/// Type information for a [map-like] type.
225226
///

0 commit comments

Comments
 (0)