File tree Expand file tree Collapse file tree 4 files changed +9
-7
lines changed
examples/dodge-the-creeps/rust/src
itest/rust/src/builtin_tests/containers Expand file tree Collapse file tree 4 files changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -105,10 +105,7 @@ impl Main {
105105 mob. set_linear_velocity ( lin_vel) ;
106106
107107 let mut hud = self . base . get_node_as :: < Hud > ( "Hud" ) ;
108- hud. connect (
109- "start_game" . into ( ) ,
110- Callable :: from_object_method ( mob, "on_start_game" ) ,
111- ) ;
108+ hud. connect ( "start_game" . into ( ) , mob. callable ( "on_start_game" ) ) ;
112109 }
113110
114111 fn music ( & mut self ) -> & mut AudioStreamPlayer {
Original file line number Diff line number Diff line change @@ -35,8 +35,10 @@ impl Callable {
3535
3636 /// Create a callable for the method `object::method_name`.
3737 ///
38+ /// See also [`Gd::callable()`].
39+ ///
3840 /// _Godot equivalent: `Callable(Object object, StringName method)`_
39- pub fn from_object_method < T , S > ( object : Gd < T > , method_name : S ) -> Self
41+ pub fn from_object_method < T , S > ( object : & Gd < T > , method_name : S ) -> Self
4042 where
4143 T : GodotClass , // + Inherits<Object>,
4244 S : Into < StringName > ,
Original file line number Diff line number Diff line change @@ -385,9 +385,12 @@ impl<T: GodotClass> Gd<T> {
385385 pub ( crate ) fn obj_sys ( & self ) -> sys:: GDExtensionObjectPtr {
386386 self . raw . obj_sys ( )
387387 }
388+
388389 /// Returns a callable referencing a method from this object named `method_name`.
390+ ///
391+ /// This is shorter syntax for [`Callable::from_object_method(self, method_name)`][Callable::from_object_method].
389392 pub fn callable < S : Into < StringName > > ( & self , method_name : S ) -> Callable {
390- Callable :: from_object_method ( self . clone ( ) , method_name)
393+ Callable :: from_object_method ( self , method_name)
391394 }
392395}
393396
Original file line number Diff line number Diff line change @@ -110,7 +110,7 @@ fn callable_call_return() {
110110#[ itest]
111111fn callable_call_engine ( ) {
112112 let obj = Node2D :: new_alloc ( ) ;
113- let cb = Callable :: from_object_method ( obj. clone ( ) , "set_position" ) ;
113+ let cb = Callable :: from_object_method ( & obj, "set_position" ) ;
114114 let inner: InnerCallable = cb. as_inner ( ) ;
115115
116116 assert ! ( !inner. is_null( ) ) ;
You can’t perform that action at this time.
0 commit comments