@@ -43,19 +43,20 @@ macro_rules! impl_packed_array {
43
43
} ,
44
44
) => {
45
45
// TODO expand type names in doc comments (use e.g. `paste` crate)
46
- /// Implements Godot's `$PackedArray` type, which is an efficient array of `$Element`s.
46
+ #[ doc = concat!( "Implements Godot's `" , stringify!( $PackedArray) , "` type," ) ]
47
+ #[ doc = concat!( "which is an efficient array of `" , stringify!( $Element) , "`s." ) ]
47
48
///
48
49
/// Note that, unlike `Array`, this type has value semantics: each copy will be independent
49
50
/// of the original. (Under the hood, Godot uses copy-on-write, so copies are still cheap
50
51
/// to make.)
51
52
///
52
53
/// # Thread safety
53
54
///
54
- /// Usage is safe if the `$PackedArray` is used on a single thread only. Concurrent reads on
55
- /// different threads are also safe, but any writes must be externally synchronized. The
56
- /// Rust compiler will enforce this as long as you use only Rust threads, but it cannot
57
- /// protect against concurrent modification on other threads (e.g. created through
58
- /// GDScript).
55
+ # [ doc = concat! ( " Usage is safe if the `" , stringify! ( $PackedArray) , "`" ) ]
56
+ /// is used on a single thread only. Concurrent reads on different threads are also safe,
57
+ /// but any writes must be externally synchronized. The Rust compiler will enforce this as
58
+ /// long as you use only Rust threads, but it cannot protect against concurrent modification
59
+ /// on other threads (e.g. created through GDScript).
59
60
#[ repr( C ) ]
60
61
pub struct $PackedArray {
61
62
opaque: $Opaque,
@@ -356,9 +357,9 @@ macro_rules! impl_packed_array {
356
357
ptr
357
358
}
358
359
359
- /// Converts an ` $Element` into a value that can be passed into API functions. For most
360
- /// types, this is a no-op. But `u8` and `i32` are widened to `i64`, and `real` is
361
- /// widened to `f64` if it is an `f32`.
360
+ # [ doc = concat! ( " Converts a `" , stringify! ( $Element) , " ` into a value that can be" ) ]
361
+ /// passed into API functions. For most types, this is a no-op. But `u8` and `i32` are
362
+ /// widened to `i64`, and `real` is widened to ` f64` if it is an `f32`.
362
363
#[ inline]
363
364
fn into_arg( e: $Element) -> $Arg {
364
365
e. into( )
@@ -376,14 +377,14 @@ macro_rules! impl_packed_array {
376
377
}
377
378
}
378
379
379
- /// Creates a `$PackedArray` from the given Rust array.
380
+ # [ doc = concat! ( " Creates a `" , stringify! ( $PackedArray) , " ` from the given Rust array." ) ]
380
381
impl <const N : usize > From <& [ $Element; N ] > for $PackedArray {
381
382
fn from( arr: & [ $Element; N ] ) -> Self {
382
383
Self :: from( & arr[ ..] )
383
384
}
384
385
}
385
386
386
- /// Creates a `$PackedArray` from the given slice.
387
+ # [ doc = concat! ( " Creates a `" , stringify! ( $PackedArray) , " ` from the given slice." ) ]
387
388
impl From <& [ $Element] > for $PackedArray {
388
389
fn from( slice: & [ $Element] ) -> Self {
389
390
let mut array = Self :: new( ) ;
@@ -405,7 +406,7 @@ macro_rules! impl_packed_array {
405
406
}
406
407
}
407
408
408
- /// Creates a `$PackedArray` from an iterator.
409
+ # [ doc = concat! ( " Creates a `" , stringify! ( $PackedArray) , " ` from an iterator." ) ]
409
410
impl FromIterator <$Element> for $PackedArray {
410
411
fn from_iter<I : IntoIterator <Item = $Element>>( iter: I ) -> Self {
411
412
let mut array = $PackedArray:: default ( ) ;
@@ -414,7 +415,7 @@ macro_rules! impl_packed_array {
414
415
}
415
416
}
416
417
417
- /// Extends a ` $PackedArray` with the contents of an iterator.
418
+ # [ doc = concat! ( " Extends a`" , stringify! ( $PackedArray) , " ` with the contents of an iterator" ) ]
418
419
impl Extend <$Element> for $PackedArray {
419
420
fn extend<I : IntoIterator <Item = $Element>>( & mut self , iter: I ) {
420
421
// Unfortunately the GDExtension API does not offer the equivalent of `Vec::reserve`.
0 commit comments