Skip to content

Commit 4c283d4

Browse files
committed
Rename ApiParam::value_to_arg() -> owned_to_arg(), hide Arg type
1 parent 387bd81 commit 4c283d4

File tree

4 files changed

+13
-12
lines changed

4 files changed

+13
-12
lines changed

godot-core/src/builtin/collections/array.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,7 @@ impl<'r, T: ArrayElement> AsArg<Array<T>> for &'r Array<T> {
947947
impl<T: ArrayElement> ApiParam for Array<T> {
948948
type Arg<'v> = CowArg<'v, Self>;
949949

950-
fn value_to_arg<'v>(self) -> Self::Arg<'v> {
950+
fn owned_to_arg<'v>(self) -> Self::Arg<'v> {
951951
CowArg::Owned(self)
952952
}
953953

@@ -1221,7 +1221,7 @@ impl<T: ArrayElement + ToGodot> Extend<T> for Array<T> {
12211221
// A faster implementation using `resize()` and direct pointer writes might still be possible.
12221222
// Note that this could technically also use iter(), since no moves need to happen (however Extend requires IntoIterator).
12231223
for item in iter.into_iter() {
1224-
self.push(ApiParam::value_to_arg(item));
1224+
self.push(ApiParam::owned_to_arg(item));
12251225
}
12261226
}
12271227
}

godot-core/src/builtin/collections/packed_array.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ macro_rules! impl_packed_array {
491491
// A faster implementation using `resize()` and direct pointer writes might still be
492492
// possible.
493493
for item in iter.into_iter() {
494-
self.push(meta::ApiParam::value_to_arg(item));
494+
self.push(meta::ApiParam::owned_to_arg(item));
495495
}
496496
}
497497
}

godot-core/src/meta/as_arg.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use std::ffi::CStr;
2323
/// Implicitly converting from `T` for by-ref builtins is explicitly not supported. This emphasizes that there is no need to consume the object,
2424
/// thus discourages unnecessary cloning.
2525
///
26-
/// If you need to pass owned values in generic code, you can use [`ApiParam::value_to_arg()`].
26+
/// If you need to pass owned values in generic code, you can use [`ApiParam::owned_to_arg()`].
2727
///
2828
/// # Performance for strings
2929
/// Godot has three string types: [`GString`], [`StringName`] and [`NodePath`]. Conversions between those three, as well as between `String` and
@@ -106,7 +106,7 @@ macro_rules! impl_asarg_by_value {
106106
impl $crate::meta::ApiParam for $T {
107107
type Arg<'v> = $T;
108108

109-
fn value_to_arg<'v>(self) -> Self::Arg<'v> {
109+
fn owned_to_arg<'v>(self) -> Self::Arg<'v> {
110110
self
111111
}
112112

@@ -139,7 +139,7 @@ macro_rules! impl_asarg_by_ref {
139139
impl $crate::meta::ApiParam for $T {
140140
type Arg<'v> = $crate::meta::CowArg<'v, $T>;
141141

142-
fn value_to_arg<'v>(self) -> Self::Arg<'v> {
142+
fn owned_to_arg<'v>(self) -> Self::Arg<'v> {
143143
$crate::meta::CowArg::Owned(self)
144144
}
145145

@@ -252,22 +252,23 @@ impl AsArg<NodePath> for &String {
252252
/// Implemented for all parameter types `T` that are allowed to receive [impl `AsArg<T>`][AsArg].
253253
pub trait ApiParam: GodotType
254254
// GodotType bound not required right now, but conceptually should always be the case.
255-
where
256-
Self: Sized,
257255
{
258256
/// Canonical argument passing type, either `T` or an internally-used CoW type.
259257
///
260258
/// The general rule is that `Copy` types are passed by value, while the rest is passed by reference.
261259
///
262-
/// This associated type is closely related to [`ToGodot::ToVia<'v>`][crate::meta::ToGodot::ToVia] and may be reorganized.
260+
/// This associated type is closely related to [`ToGodot::ToVia<'v>`][crate::meta::ToGodot::ToVia] and may be reorganized in the future.
261+
#[doc(hidden)]
263262
type Arg<'v>: AsArg<Self>
264263
where
265264
Self: 'v;
266265

267266
/// Converts an owned value to the canonical argument type, which can be passed to [`impl AsArg<T>`][AsArg].
268267
///
269268
/// Useful in generic contexts where only a value is available, and one doesn't want to dispatch between value/reference.
270-
fn value_to_arg<'v>(self) -> Self::Arg<'v>;
269+
///
270+
/// You should not rely on the exact return type, as it may change in future versions; treat it like `impl AsArg<Self>`.
271+
fn owned_to_arg<'v>(self) -> Self::Arg<'v>;
271272

272273
/// Converts an argument to a shared reference.
273274
///

godot-core/src/obj/gd.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ impl<'r, T: GodotClass> AsArg<Gd<T>> for &'r Gd<T> {
784784
impl<T: GodotClass> ApiParam for Gd<T> {
785785
type Arg<'v> = CowArg<'v, Gd<T>>;
786786

787-
fn value_to_arg<'v>(self) -> Self::Arg<'v> {
787+
fn owned_to_arg<'v>(self) -> Self::Arg<'v> {
788788
CowArg::Owned(self)
789789
}
790790

@@ -806,7 +806,7 @@ impl<'r, T: GodotClass> AsArg<Option<Gd<T>>> for Option<&'r Gd<T>> {
806806
impl<T: GodotClass> ApiParam for Option<Gd<T>> {
807807
type Arg<'v> = CowArg<'v, Option<Gd<T>>>;
808808

809-
fn value_to_arg<'v>(self) -> Self::Arg<'v> {
809+
fn owned_to_arg<'v>(self) -> Self::Arg<'v> {
810810
CowArg::Owned(self)
811811
}
812812

0 commit comments

Comments
 (0)