@@ -109,6 +109,22 @@ use sys::{ffi_methods, interface_fn, GodotFfi};
109
109
/// compiler will enforce this as long as you use only Rust threads, but it cannot protect against
110
110
/// concurrent modification on other threads (e.g. created through GDScript).
111
111
///
112
+ /// # Element type safety
113
+ ///
114
+ /// We provide a richer set of element types than Godot, for convenience and stronger invariants in your _Rust_ code.
115
+ /// This, however, means that the Godot representation of such arrays is not capable of incorporating the additional "Rust-side" information.
116
+ /// This can lead to situations where GDScript code or the editor UI can insert values that do not fulfill the Rust-side invariants.
117
+ /// The library offers some best-effort protection in Debug mode, but certain errors may only occur on element access, in the form of panics.
118
+ ///
119
+ /// Concretely, the following types lose type information when passed to Godot. If you want 100% bullet-proof arrays, avoid those.
120
+ /// - Non-`i64` integers: `i8`, `i16`, `i32`, `u8`, `u16`, `u32`. (`u64` is unsupported).
121
+ /// - Non-`f64` floats: `f32`.
122
+ /// - Non-null objects: [`Gd<T>`][crate::obj::Gd].
123
+ /// Godot generally allows `null` in arrays due to default-constructability, e.g. when using `resize()`.
124
+ /// The Godot-faithful (but less convenient) alternative is to use `Option<Gd<T>>` element types.
125
+ /// - Objects with dyn-trait association: [`DynGd<T, D>`][crate::obj::DynGd].
126
+ /// Godot doesn't know Rust traits and will only see the `T` part.
127
+ ///
112
128
/// # Godot docs
113
129
///
114
130
/// [`Array[T]` (stable)](https://docs.godotengine.org/en/stable/classes/class_array.html)
0 commit comments