From 2772e080d6f3e997d4e6a1193d8ca941dc6a9a79 Mon Sep 17 00:00:00 2001 From: mio991 Date: Thu, 9 Mar 2023 11:48:38 +0100 Subject: [PATCH] Enums implement Default --- godot-codegen/src/util.rs | 2 +- godot-core/src/obj/traits.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/godot-codegen/src/util.rs b/godot-codegen/src/util.rs index e599e170e..7d320f5d7 100644 --- a/godot-codegen/src/util.rs +++ b/godot-codegen/src/util.rs @@ -63,7 +63,7 @@ pub fn make_enum_definition(enum_: &Enum) -> TokenStream { // TODO maybe generalize GodotFfi over EngineEnum trait quote! { #[repr(transparent)] - #[derive(Copy, Clone, Eq, PartialEq, Debug, Hash)] + #[derive(Copy, Clone, Eq, PartialEq, Debug, Hash, Default)] pub struct #enum_name { ord: i32 } diff --git a/godot-core/src/obj/traits.rs b/godot-core/src/obj/traits.rs index 748ff1363..acfcb2f4c 100644 --- a/godot-core/src/obj/traits.rs +++ b/godot-core/src/obj/traits.rs @@ -103,7 +103,7 @@ pub trait EngineClass: GodotClass { } /// Auto-implemented for all engine-provided enums -pub trait EngineEnum: Copy { +pub trait EngineEnum: Copy + Default { fn try_from_ord(ord: i32) -> Option; /// Ordinal value of the enumerator, as specified in Godot.