File tree 2 files changed +16
-10
lines changed
2 files changed +16
-10
lines changed Original file line number Diff line number Diff line change @@ -649,14 +649,7 @@ impl<T: GodotClass> PartialEq for Gd<T> {
649
649
650
650
impl < T : GodotClass > Eq for Gd < T > { }
651
651
652
- impl < T > Display for Gd < T >
653
- where
654
- T : GodotClass < Declarer = dom:: EngineDomain > ,
655
- {
656
- // TODO support for user objects? should it return the engine repr, or a custom <T as Display>::fmt()?
657
- // If the latter, we would need to do something like impl<T> Display for Gd<T> where T: Display,
658
- // and thus implement it for each class separately (or blanket GodotClass/EngineClass/...).
659
-
652
+ impl < T : GodotClass > Display for Gd < T > {
660
653
fn fmt ( & self , f : & mut Formatter < ' _ > ) -> FmtResult {
661
654
engine:: display_string ( self , f)
662
655
}
Original file line number Diff line number Diff line change @@ -115,7 +115,17 @@ fn object_engine_roundtrip() {
115
115
}
116
116
117
117
#[ itest]
118
- fn object_display ( ) {
118
+ fn object_user_display ( ) {
119
+ let obj = Gd :: new ( ObjPayload { value : 774 } ) ;
120
+
121
+ let actual = format ! ( ".:{obj}:." ) ;
122
+ let expected = ".:value=774:." . to_string ( ) ;
123
+
124
+ assert_eq ! ( actual, expected) ;
125
+ }
126
+
127
+ #[ itest]
128
+ fn object_engine_display ( ) {
119
129
let obj = Node3D :: new_alloc ( ) ;
120
130
let id = obj. instance_id ( ) ;
121
131
@@ -631,7 +641,6 @@ fn user_object() -> Gd<ObjPayload> {
631
641
}
632
642
633
643
#[ derive( GodotClass , Debug , Eq , PartialEq ) ]
634
- //#[class(init)]
635
644
pub struct ObjPayload {
636
645
value : i16 ,
637
646
}
@@ -641,6 +650,10 @@ impl RefCountedVirtual for ObjPayload {
641
650
fn init ( _base : Base < Self :: Base > ) -> Self {
642
651
Self { value : 111 }
643
652
}
653
+
654
+ fn to_string ( & self ) -> GodotString {
655
+ format ! ( "value={}" , self . value) . into ( )
656
+ }
644
657
}
645
658
646
659
// ----------------------------------------------------------------------------------------------------------------------------------------------
You can’t perform that action at this time.
0 commit comments