Skip to content

Commit 7e1d30f

Browse files
committed
Rename InvalidSize to InvalidLength and cargo fmt
1 parent c5370d4 commit 7e1d30f

File tree

3 files changed

+24
-22
lines changed

3 files changed

+24
-22
lines changed

crates/bevy_reflect/src/from_reflect.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ impl<T: FromReflect> FromType<T> for ReflectFromReflect {
116116

117117
/// An Error for failed conversion of reflected type to original type in [`FromReflect::from_reflect`].
118118
///
119-
/// In the error message, the kind of the source type may have a prefix "(Dynamic)" indicating that the
119+
/// In the error message, the kind of the source type may have a prefix "(Dynamic)" indicating that the
120120
/// source is dynamic, i.e., [`DynamicStruct`], [`DynamicList`], etc.
121121
///
122122
/// Within variants `NamedFieldError`, `UnnamedFieldError`, `IndexError`, `VariantError`, `KeyError` and
@@ -146,13 +146,13 @@ pub enum FromReflectError {
146146
/// This error is given by types of [kind](ReflectKind) [`Array`](crate::Array).
147147
#[error("The reflected type `{}` of kind {} cannot be converted to type `{}` due to source type having length of {} and target type having length of {}",
148148
.from_type.type_name(), self.display_from_kind(), .to_type.type_name(), .from_len, .to_len)]
149-
InvalidSize {
149+
InvalidLength {
150150
/// [`TypeInfo`] of the source type.
151151
from_type: &'static TypeInfo,
152152

153153
/// [`ReflectKind`] of the source type.
154154
from_kind: ReflectKind,
155-
155+
156156
/// [`TypeInfo`] of the target type.
157157
to_type: &'static TypeInfo,
158158

@@ -192,7 +192,7 @@ pub enum FromReflectError {
192192
MissingUnnamedField {
193193
/// [`TypeInfo`] of the source type.
194194
from_type: &'static TypeInfo,
195-
195+
196196
/// [`ReflectKind`] of the source type.
197197
from_kind: ReflectKind,
198198

@@ -230,7 +230,7 @@ pub enum FromReflectError {
230230
MissingVariant {
231231
/// [`TypeInfo`] of the source type.
232232
from_type: &'static TypeInfo,
233-
233+
234234
/// [`ReflectKind`] of the source type.
235235
from_kind: ReflectKind,
236236

@@ -280,7 +280,7 @@ pub enum FromReflectError {
280280

281281
/// [`ReflectKind`] of the source type.
282282
from_kind: ReflectKind,
283-
283+
284284
/// [`TypeInfo`] of the target type.
285285
to_type: &'static TypeInfo,
286286

@@ -295,7 +295,7 @@ pub enum FromReflectError {
295295
///
296296
/// Use [`Error::source`](std::error::Error::source) to get the underlying error.
297297
///
298-
/// This error is given by types of [kind](ReflectKind) [`List`](crate::List) and
298+
/// This error is given by types of [kind](ReflectKind) [`List`](crate::List) and
299299
/// [`Enum`](crate::Enum).
300300
#[error("The reflected type `{}` of kind {} cannot be converted to type `{}` due to an error in the value at index `{}`",
301301
.from_type.type_name(), self.display_from_kind(), .to_type.type_name(), .index)]
@@ -326,7 +326,7 @@ pub enum FromReflectError {
326326
VariantError {
327327
/// [`TypeInfo`] of the source type.
328328
from_type: &'static TypeInfo,
329-
329+
330330
/// [`ReflectKind`] of the source type.
331331
from_kind: ReflectKind,
332332

@@ -371,7 +371,7 @@ pub enum FromReflectError {
371371
ValueError {
372372
/// [`TypeInfo`] of the source type.
373373
from_type: &'static TypeInfo,
374-
374+
375375
/// [`ReflectKind`] of the source type.
376376
from_kind: ReflectKind,
377377

@@ -388,7 +388,7 @@ impl FromReflectError {
388388
pub fn from_type(&self) -> &'static TypeInfo {
389389
match self {
390390
Self::InvalidType { from_type, .. }
391-
| Self::InvalidSize { from_type, .. }
391+
| Self::InvalidLength { from_type, .. }
392392
| Self::MissingNamedField { from_type, .. }
393393
| Self::MissingUnnamedField { from_type, .. }
394394
| Self::MissingIndex { from_type, .. }
@@ -406,7 +406,7 @@ impl FromReflectError {
406406
pub fn to_type(&self) -> &'static TypeInfo {
407407
match self {
408408
Self::InvalidType { to_type, .. }
409-
| Self::InvalidSize { to_type, .. }
409+
| Self::InvalidLength { to_type, .. }
410410
| Self::MissingNamedField { to_type, .. }
411411
| Self::MissingUnnamedField { to_type, .. }
412412
| Self::MissingIndex { to_type, .. }
@@ -424,7 +424,7 @@ impl FromReflectError {
424424
pub fn from_kind(&self) -> ReflectKind {
425425
*match self {
426426
Self::InvalidType { from_kind, .. }
427-
| Self::InvalidSize { from_kind, .. }
427+
| Self::InvalidLength { from_kind, .. }
428428
| Self::MissingNamedField { from_kind, .. }
429429
| Self::MissingUnnamedField { from_kind, .. }
430430
| Self::MissingIndex { from_kind, .. }

crates/bevy_reflect/src/impls/std.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ impl<T: FromReflect, const N: usize> FromReflect for [T; N] {
706706
let temp_vec_len = temp_vec.len();
707707
temp_vec
708708
.try_into()
709-
.map_err(|_| FromReflectError::InvalidSize {
709+
.map_err(|_| FromReflectError::InvalidLength {
710710
from_type: reflect.get_type_info(),
711711
from_kind: reflect.reflect_kind(),
712712
to_type: Self::type_info(),
@@ -967,12 +967,14 @@ impl<T: FromReflect> FromReflect for Option<T> {
967967
})?
968968
.clone_value(),
969969
)
970-
.map_err(|(_, err)| FromReflectError::UnnamedFieldError {
971-
from_type: reflect.get_type_info(),
972-
from_kind: reflect.reflect_kind(),
973-
to_type: Self::type_info(),
974-
index: 0,
975-
source: Box::new(err),
970+
.map_err(|(_, err)| {
971+
FromReflectError::UnnamedFieldError {
972+
from_type: reflect.get_type_info(),
973+
from_kind: reflect.reflect_kind(),
974+
to_type: Self::type_info(),
975+
index: 0,
976+
source: Box::new(err),
977+
}
976978
})
977979
})()
978980
.map_err(|err| FromReflectError::VariantError {

crates/bevy_reflect/src/reflect.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ use crate::utility::NonGenericTypeInfoCell;
1212
pub use bevy_utils::AHasher as ReflectHasher;
1313

1414
/// A simple enumeration of [kinds](ReflectKind) of type, without any associated object.
15-
///
15+
///
1616
/// All types implementing [`Reflect`] are categorized into "kinds". They help to group types that
1717
/// behave similarly and provide methods specific to its kind. These kinds directly correspond to
18-
/// the traits [`Struct`], [`TupleStruct`], [`Tuple`], [`List`], [`Array`], [`Map`] and [`Enum`];
18+
/// the traits [`Struct`], [`TupleStruct`], [`Tuple`], [`List`], [`Array`], [`Map`] and [`Enum`];
1919
/// which means that a type implementing any one of the above traits will be of the corresponding
2020
/// kind. All the remaining types will be `ReflectKind::Value`.
2121
///
@@ -86,7 +86,7 @@ pub enum ReflectOwned {
8686
/// A reflected Rust type.
8787
///
8888
/// Methods for working with particular [kinds](ReflectKind) of Rust type are available using
89-
/// the [`Array`], [`List`], [`Map`], [`Tuple`], [`TupleStruct`], [`Struct`], and [`Enum`] subtraits.
89+
/// the [`Array`], [`List`], [`Map`], [`Tuple`], [`TupleStruct`], [`Struct`], and [`Enum`] subtraits.
9090
///
9191
/// When using `#[derive(Reflect)]` on a struct, tuple struct or enum, the suitable subtrait for that
9292
/// type (`Struct`, `TupleStruct` or `Enum`) is derived automatically.

0 commit comments

Comments
 (0)