Skip to content

Commit a7402e8

Browse files
authored
Merge pull request #433 from dataphract/doc/packed-array-names
doc: use actual type names in `Packed*Array` documentation
2 parents d2ce6b8 + fbf45f9 commit a7402e8

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

godot-core/src/builtin/packed_array.rs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,20 @@ macro_rules! impl_packed_array {
4343
},
4444
) => {
4545
// 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.")]
4748
///
4849
/// Note that, unlike `Array`, this type has value semantics: each copy will be independent
4950
/// of the original. (Under the hood, Godot uses copy-on-write, so copies are still cheap
5051
/// to make.)
5152
///
5253
/// # Thread safety
5354
///
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).
5960
#[repr(C)]
6061
pub struct $PackedArray {
6162
opaque: $Opaque,
@@ -356,9 +357,9 @@ macro_rules! impl_packed_array {
356357
ptr
357358
}
358359

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`.
362363
#[inline]
363364
fn into_arg(e: $Element) -> $Arg {
364365
e.into()
@@ -376,14 +377,14 @@ macro_rules! impl_packed_array {
376377
}
377378
}
378379

379-
/// Creates a `$PackedArray` from the given Rust array.
380+
#[doc = concat!("Creates a `", stringify!($PackedArray), "` from the given Rust array.")]
380381
impl<const N: usize> From<&[$Element; N]> for $PackedArray {
381382
fn from(arr: &[$Element; N]) -> Self {
382383
Self::from(&arr[..])
383384
}
384385
}
385386

386-
/// Creates a `$PackedArray` from the given slice.
387+
#[doc = concat!("Creates a `", stringify!($PackedArray), "` from the given slice.")]
387388
impl From<&[$Element]> for $PackedArray {
388389
fn from(slice: &[$Element]) -> Self {
389390
let mut array = Self::new();
@@ -405,7 +406,7 @@ macro_rules! impl_packed_array {
405406
}
406407
}
407408

408-
/// Creates a `$PackedArray` from an iterator.
409+
#[doc = concat!("Creates a `", stringify!($PackedArray), "` from an iterator.")]
409410
impl FromIterator<$Element> for $PackedArray {
410411
fn from_iter<I: IntoIterator<Item = $Element>>(iter: I) -> Self {
411412
let mut array = $PackedArray::default();
@@ -414,7 +415,7 @@ macro_rules! impl_packed_array {
414415
}
415416
}
416417

417-
/// Extends a `$PackedArray` with the contents of an iterator.
418+
#[doc = concat!("Extends a`", stringify!($PackedArray), "` with the contents of an iterator")]
418419
impl Extend<$Element> for $PackedArray {
419420
fn extend<I: IntoIterator<Item = $Element>>(&mut self, iter: I) {
420421
// Unfortunately the GDExtension API does not offer the equivalent of `Vec::reserve`.

0 commit comments

Comments
 (0)