Skip to content

Commit 65edd1e

Browse files
committed
Added Function to PartialReflect::debug
1 parent 4b5ee60 commit 65edd1e

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

crates/bevy_reflect/src/func/function.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::func::{ArgList, FunctionInfo, FunctionResult};
22
use crate::PartialReflect;
33
use alloc::borrow::Cow;
4+
use core::fmt::Debug;
45
use downcast_rs::{impl_downcast, Downcast};
56

67
/// A trait used to power [function-like] operations via [reflection].
@@ -30,7 +31,7 @@ use downcast_rs::{impl_downcast, Downcast};
3031
/// [`Reflect`]: crate::Reflect
3132
/// [arguments]: crate::func::args
3233
/// [`DynamicFunction`]: crate::func::DynamicFunction
33-
pub trait Function: PartialReflect + Downcast {
34+
pub trait Function: PartialReflect + Downcast + Debug {
3435
/// The name of the function, if any.
3536
///
3637
/// For [`DynamicFunctions`] created using [`IntoFunction`],

crates/bevy_reflect/src/reflect.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::{
2-
array_debug, enum_debug, list_debug, map_debug, serde::Serializable, struct_debug, tuple_debug,
3-
tuple_struct_debug, Array, DynamicTypePath, DynamicTyped, Enum, List, Map, Set, Struct, Tuple,
4-
TupleStruct, TypeInfo, TypePath, Typed, ValueInfo,
2+
array_debug, enum_debug, list_debug, map_debug, serde::Serializable, set_debug, struct_debug,
3+
tuple_debug, tuple_struct_debug, Array, DynamicTypePath, DynamicTyped, Enum, List, Map, Set,
4+
Struct, Tuple, TupleStruct, TypeInfo, TypePath, Typed, ValueInfo,
55
};
66
use std::{
77
any::{Any, TypeId},
@@ -375,8 +375,11 @@ where
375375
ReflectRef::List(dyn_list) => list_debug(dyn_list, f),
376376
ReflectRef::Array(dyn_array) => array_debug(dyn_array, f),
377377
ReflectRef::Map(dyn_map) => map_debug(dyn_map, f),
378+
ReflectRef::Set(dyn_set) => set_debug(dyn_set, f),
378379
ReflectRef::Enum(dyn_enum) => enum_debug(dyn_enum, f),
379-
_ => write!(f, "Reflect({})", self.reflect_type_path()),
380+
#[cfg(feature = "functions")]
381+
ReflectRef::Function(dyn_function) => dyn_function.fmt(f),
382+
ReflectRef::Value(_) => write!(f, "Reflect({})", self.reflect_type_path()),
380383
}
381384
}
382385

0 commit comments

Comments
 (0)