diff --git a/godot-core/src/builtin/collections/array.rs b/godot-core/src/builtin/collections/array.rs index 754220a87..9db47f65f 100644 --- a/godot-core/src/builtin/collections/array.rs +++ b/godot-core/src/builtin/collections/array.rs @@ -985,7 +985,10 @@ impl Var for Array { } } -impl Export for Array { +impl Export for Array +where + T: Export, +{ fn export_hint() -> PropertyHintInfo { // If T == Variant, then we return "Array" builtin type hint. if Self::has_variant_t() { diff --git a/godot-core/src/registry/property.rs b/godot-core/src/registry/property.rs index 59ed9daf0..9ea10a470 100644 --- a/godot-core/src/registry/property.rs +++ b/godot-core/src/registry/property.rs @@ -65,6 +65,47 @@ pub trait Export: Var { } } +/// This function only exists as a place to add doc-tests for the `Export` trait. +/// +/// Test with export of exportable type should succeed: +/// ```no_run +/// use godot::prelude::*; +/// +/// #[derive(GodotClass)] +/// #[class(init)] +/// struct Foo { +/// #[export] +/// obj: Option>, +/// #[export] +/// array: Array>, +/// } +/// ``` +/// +/// Tests with export of non-exportable type should fail: +/// ```compile_fail +/// use godot::prelude::*; +/// +/// #[derive(GodotClass)] +/// #[class(init)] +/// struct Foo { +/// #[export] +/// obj: Option>, +/// } +/// ``` +/// +/// ```compile_fail +/// use godot::prelude::*; +/// +/// #[derive(GodotClass)] +/// #[class(init)] +/// struct Foo { +/// #[export] +/// array: Array>, +/// } +/// ``` +#[allow(dead_code)] +fn export_doctests() {} + // ---------------------------------------------------------------------------------------------------------------------------------------------- // Blanket impls for Option