@@ -12,7 +12,7 @@ use crate::private::get_api;
12
12
/// A reference-counted CoW typed vector using Godot's pool allocator, generic over possible
13
13
/// element types.
14
14
///
15
- /// `TypedArray ` unifies all the different `Pool*Array` types exported by Godot. It can be used
15
+ /// `PoolArray ` unifies all the different `Pool*Array` types exported by Godot. It can be used
16
16
/// in exported Rust methods as parameter and return types, as well as in exported properties.
17
17
/// However, it is limited to the element types, for which a `Pool*Array` exists in GDScript,
18
18
/// i.e. it cannot contain user-defined types.
@@ -25,7 +25,7 @@ use crate::private::get_api;
25
25
/// When using this type, it's generally better to perform mutations in batch using `write`,
26
26
/// or the `append` methods, as opposed to `push` or `set`, because the latter ones trigger
27
27
/// CoW behavior each time they are called.
28
- pub struct TypedArray < T : Element > {
28
+ pub struct PoolArray < T : Element > {
29
29
inner : T :: SysArray ,
30
30
}
31
31
@@ -36,7 +36,7 @@ pub type Read<'a, T> = Aligned<ReadGuard<'a, T>>;
36
36
/// as opposed to every time with methods like `push`.
37
37
pub type Write < ' a , T > = Aligned < WriteGuard < ' a , T > > ;
38
38
39
- impl < T : Element > Drop for TypedArray < T > {
39
+ impl < T : Element > Drop for PoolArray < T > {
40
40
#[ inline]
41
41
fn drop ( & mut self ) {
42
42
unsafe {
@@ -45,47 +45,47 @@ impl<T: Element> Drop for TypedArray<T> {
45
45
}
46
46
}
47
47
48
- impl < T : Element > Default for TypedArray < T > {
48
+ impl < T : Element > Default for PoolArray < T > {
49
49
#[ inline]
50
50
fn default ( ) -> Self {
51
- TypedArray :: new ( )
51
+ PoolArray :: new ( )
52
52
}
53
53
}
54
54
55
- impl < T : Element + fmt:: Debug > fmt:: Debug for TypedArray < T > {
55
+ impl < T : Element + fmt:: Debug > fmt:: Debug for PoolArray < T > {
56
56
#[ inline]
57
57
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
58
58
f. debug_list ( ) . entries ( self . read ( ) . iter ( ) ) . finish ( )
59
59
}
60
60
}
61
61
62
- impl < T : Element > Clone for TypedArray < T > {
62
+ impl < T : Element > Clone for PoolArray < T > {
63
63
#[ inline]
64
64
fn clone ( & self ) -> Self {
65
65
self . new_ref ( )
66
66
}
67
67
}
68
68
69
- impl < T : Element > NewRef for TypedArray < T > {
69
+ impl < T : Element > NewRef for PoolArray < T > {
70
70
/// Creates a new reference to this reference-counted instance.
71
71
#[ inline]
72
72
fn new_ref ( & self ) -> Self {
73
73
unsafe {
74
74
let mut inner = T :: SysArray :: default ( ) ;
75
75
( T :: new_copy_fn ( get_api ( ) ) ) ( & mut inner, self . sys ( ) ) ;
76
- TypedArray { inner }
76
+ PoolArray { inner }
77
77
}
78
78
}
79
79
}
80
80
81
- impl < T : Element > TypedArray < T > {
81
+ impl < T : Element > PoolArray < T > {
82
82
/// Creates an empty array.
83
83
#[ inline]
84
84
pub fn new ( ) -> Self {
85
85
unsafe {
86
86
let mut inner = T :: SysArray :: default ( ) ;
87
87
( T :: new_fn ( get_api ( ) ) ) ( & mut inner) ;
88
- TypedArray { inner }
88
+ PoolArray { inner }
89
89
}
90
90
}
91
91
@@ -95,11 +95,11 @@ impl<T: Element> TypedArray<T> {
95
95
unsafe {
96
96
let mut inner = T :: SysArray :: default ( ) ;
97
97
( T :: new_with_array_fn ( get_api ( ) ) ) ( & mut inner, array. sys ( ) ) ;
98
- TypedArray { inner }
98
+ PoolArray { inner }
99
99
}
100
100
}
101
101
102
- /// Creates a `TypedArray ` moving elements from `src`.
102
+ /// Creates a `PoolArray ` moving elements from `src`.
103
103
#[ inline]
104
104
pub fn from_vec ( mut src : Vec < T > ) -> Self {
105
105
let mut arr = Self :: new ( ) ;
@@ -261,12 +261,12 @@ impl<T: Element> TypedArray<T> {
261
261
#[ doc( hidden) ]
262
262
#[ inline]
263
263
pub fn from_sys ( sys : T :: SysArray ) -> Self {
264
- TypedArray { inner : sys }
264
+ PoolArray { inner : sys }
265
265
}
266
266
}
267
267
268
- impl < T : Element + Copy > TypedArray < T > {
269
- /// Creates a new `TypedArray ` by copying from `src`.
268
+ impl < T : Element + Copy > PoolArray < T > {
269
+ /// Creates a new `PoolArray ` by copying from `src`.
270
270
///
271
271
/// # Panics
272
272
///
@@ -297,23 +297,23 @@ impl<T: Element + Copy> TypedArray<T> {
297
297
// `FromIterator` and `Extend` implementations collect into `Vec` first, because Rust `Vec`s
298
298
// are better at handling unknown lengths than the Godot arrays (`push` CoWs every time!)
299
299
300
- impl < T : Element > FromIterator < T > for TypedArray < T > {
300
+ impl < T : Element > FromIterator < T > for PoolArray < T > {
301
301
#[ inline]
302
302
fn from_iter < I : IntoIterator < Item = T > > ( iter : I ) -> Self {
303
303
let vec = iter. into_iter ( ) . collect :: < Vec < _ > > ( ) ;
304
304
Self :: from_vec ( vec)
305
305
}
306
306
}
307
307
308
- impl < T : Element > Extend < T > for TypedArray < T > {
308
+ impl < T : Element > Extend < T > for PoolArray < T > {
309
309
#[ inline]
310
310
fn extend < I : IntoIterator < Item = T > > ( & mut self , iter : I ) {
311
311
let mut vec = iter. into_iter ( ) . collect :: < Vec < _ > > ( ) ;
312
312
self . append_vec ( & mut vec) ;
313
313
}
314
314
}
315
315
316
- impl < T : Element + PartialEq > PartialEq for TypedArray < T > {
316
+ impl < T : Element + PartialEq > PartialEq for PoolArray < T > {
317
317
#[ inline]
318
318
fn eq ( & self , other : & Self ) -> bool {
319
319
if self . len ( ) != other. len ( ) {
@@ -326,7 +326,7 @@ impl<T: Element + PartialEq> PartialEq for TypedArray<T> {
326
326
left. as_slice ( ) == right. as_slice ( )
327
327
}
328
328
}
329
- impl < T : Element + Eq > Eq for TypedArray < T > { }
329
+ impl < T : Element + Eq > Eq for PoolArray < T > { }
330
330
331
331
/// RAII read guard.
332
332
pub struct ReadGuard < ' a , T : Element > {
@@ -437,7 +437,7 @@ impl<'a, T: Element> Drop for WriteGuard<'a, T> {
437
437
}
438
438
439
439
macros:: decl_typed_array_element! {
440
- /// Trait for element types that can be contained in `TypedArray `. This trait is sealed
440
+ /// Trait for element types that can be contained in `PoolArray `. This trait is sealed
441
441
/// and has no public interface.
442
442
pub trait Element : private:: Sealed { .. }
443
443
}
@@ -495,7 +495,7 @@ mod serialize {
495
495
use std:: fmt:: Formatter ;
496
496
use std:: marker:: PhantomData ;
497
497
498
- impl < T : Serialize + Element > Serialize for TypedArray < T > {
498
+ impl < T : Serialize + Element > Serialize for PoolArray < T > {
499
499
#[ inline]
500
500
fn serialize < S > ( & self , ser : S ) -> Result < <S as Serializer >:: Ok , <S as Serializer >:: Error >
501
501
where
@@ -510,15 +510,15 @@ mod serialize {
510
510
}
511
511
}
512
512
513
- impl < ' de , T : Deserialize < ' de > + Element > Deserialize < ' de > for TypedArray < T > {
513
+ impl < ' de , T : Deserialize < ' de > + Element > Deserialize < ' de > for PoolArray < T > {
514
514
#[ inline]
515
515
fn deserialize < D > ( deserializer : D ) -> Result < Self , <D as Deserializer < ' de > >:: Error >
516
516
where
517
517
D : Deserializer < ' de > ,
518
518
{
519
519
struct TypedArrayVisitor < T > ( PhantomData < T > ) ;
520
520
impl < ' de , T : Deserialize < ' de > + Element > Visitor < ' de > for TypedArrayVisitor < T > {
521
- type Value = TypedArray < T > ;
521
+ type Value = PoolArray < T > ;
522
522
523
523
fn expecting ( & self , formatter : & mut Formatter ) -> fmt:: Result {
524
524
formatter. write_str ( std:: any:: type_name :: < Self :: Value > ( ) )
0 commit comments