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 {
105
105
mob. set_linear_velocity ( lin_vel) ;
106
106
107
107
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" ) ) ;
112
109
}
113
110
114
111
fn music ( & mut self ) -> & mut AudioStreamPlayer {
Original file line number Diff line number Diff line change @@ -35,8 +35,10 @@ impl Callable {
35
35
36
36
/// Create a callable for the method `object::method_name`.
37
37
///
38
+ /// See also [`Gd::callable()`].
39
+ ///
38
40
/// _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
40
42
where
41
43
T : GodotClass , // + Inherits<Object>,
42
44
S : Into < StringName > ,
Original file line number Diff line number Diff line change @@ -385,9 +385,12 @@ impl<T: GodotClass> Gd<T> {
385
385
pub ( crate ) fn obj_sys ( & self ) -> sys:: GDExtensionObjectPtr {
386
386
self . raw . obj_sys ( )
387
387
}
388
+
388
389
/// 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].
389
392
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)
391
394
}
392
395
}
393
396
Original file line number Diff line number Diff line change @@ -110,7 +110,7 @@ fn callable_call_return() {
110
110
#[ itest]
111
111
fn callable_call_engine ( ) {
112
112
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" ) ;
114
114
let inner: InnerCallable = cb. as_inner ( ) ;
115
115
116
116
assert ! ( !inner. is_null( ) ) ;
You can’t perform that action at this time.
0 commit comments