Skip to content

Commit 50ce26b

Browse files
authored
Merge pull request #725 from godot-rust/qol/packed-array-cleanup
Make `Packed*Array` API more consistent with `Array`
2 parents d7bf5bd + 7ebe979 commit 50ce26b

File tree

6 files changed

+236
-203
lines changed

6 files changed

+236
-203
lines changed

godot-core/src/builtin/array.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ impl<T: ArrayElement> Array<T> {
242242
// SAFETY: The array has type `T` and we're writing a value of type `T` to it.
243243
unsafe { self.as_inner_mut() }.push_front(value.to_variant());
244244
}
245+
245246
/// Removes and returns the last element of the array. Returns `None` if the array is empty.
246247
///
247248
/// _Godot equivalent: `pop_back`_
@@ -266,7 +267,7 @@ impl<T: ArrayElement> Array<T> {
266267
})
267268
}
268269

269-
/// Inserts a new element before the index. The index must be valid or the end of the array (`index == len()`).
270+
/// ⚠️ Inserts a new element before the index. The index must be valid or the end of the array (`index == len()`).
270271
///
271272
/// On large arrays, this method is much slower than [`push()`][Self::push], as it will move all the array's elements after the inserted element.
272273
/// The larger the array, the slower `insert()` will be.
@@ -286,12 +287,13 @@ impl<T: ArrayElement> Array<T> {
286287

287288
/// ⚠️ Removes and returns the element at the specified index. Equivalent of `pop_at` in GDScript.
288289
///
289-
/// On large arrays, this method is much slower than `pop_back()` as it will move all the array's
290+
/// On large arrays, this method is much slower than [`pop()`][Self::pop] as it will move all the array's
290291
/// elements after the removed element. The larger the array, the slower `remove()` will be.
291292
///
292293
/// # Panics
293294
///
294295
/// If `index` is out of bounds.
296+
#[doc(alias = "pop_at")]
295297
pub fn remove(&mut self, index: usize) -> T {
296298
self.check_bounds(index);
297299

@@ -304,7 +306,7 @@ impl<T: ArrayElement> Array<T> {
304306
///
305307
/// If the value does not exist in the array, nothing happens. To remove an element by index, use [`remove()`][Self::remove] instead.
306308
///
307-
/// On large arrays, this method is much slower than [`pop_back()`][Self::pop_back], as it will move all the array's
309+
/// On large arrays, this method is much slower than [`pop()`][Self::pop], as it will move all the array's
308310
/// elements after the removed element.
309311
pub fn erase(&mut self, value: &T) {
310312
// SAFETY: We don't write anything to the array.

0 commit comments

Comments
 (0)