From 64468b22a06311549fd5da33d6ddda1f8345b7e8 Mon Sep 17 00:00:00 2001 From: patataofcourse Date: Fri, 4 Aug 2023 23:26:11 +0200 Subject: [PATCH] ci fixes --- godot-macros/src/derive_export.rs | 12 +++++++----- godot-macros/src/lib.rs | 12 ++++++++---- itest/rust/src/property_test.rs | 2 +- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/godot-macros/src/derive_export.rs b/godot-macros/src/derive_export.rs index 21f05270a..486a1a129 100644 --- a/godot-macros/src/derive_export.rs +++ b/godot-macros/src/derive_export.rs @@ -25,8 +25,7 @@ pub fn transform(decl: Declaration) -> ParseResult { _ => unreachable!(), }; - let hint_string; - if enum_.variants.is_empty() { + let hint_string = if enum_.variants.is_empty() { return bail!( enum_.name, "In order to derive Export, enums must have at least one variant" @@ -43,7 +42,10 @@ pub fn transform(decl: Declaration) -> ParseResult { "Property can only be derived on enums with explicit discriminants in all their variants" ); }; - let v_disc_trimmed = v_disc.to_string().trim_matches(['(', ')'].as_slice()).to_string(); + let v_disc_trimmed = v_disc + .to_string() + .trim_matches(['(', ')'].as_slice()) + .to_string(); hint_string_segments.push(format!("{v_name}:{v_disc_trimmed}")); @@ -57,8 +59,8 @@ pub fn transform(decl: Declaration) -> ParseResult { } }; } - hint_string = hint_string_segments.join(","); - } + hint_string_segments.join(",") + }; let out = quote! { #[allow(unused_parens)] diff --git a/godot-macros/src/lib.rs b/godot-macros/src/lib.rs index ec38a36d7..651c3dbc3 100644 --- a/godot-macros/src/lib.rs +++ b/godot-macros/src/lib.rs @@ -470,7 +470,8 @@ pub fn derive_from_variant(input: TokenStream) -> TokenStream { /// ```no_run /// # use godot::prelude::*; /// #[repr(i32)] -/// #[derive(Debug, Property)] +/// #[derive(Property)] +/// # #[derive(PartialEq, Eq, Debug)] /// enum TestEnum { /// A = 0, /// B = 1, @@ -482,11 +483,14 @@ pub fn derive_from_variant(input: TokenStream) -> TokenStream { /// foo: TestEnum /// } /// +/// # #[godot_api] +/// # impl TestClass {} +/// /// # fn main() { -/// let mut class = TestClass {foo: TestEnum::B}.get_foo(); +/// let mut class = TestClass {foo: TestEnum::B}; /// assert_eq!(class.get_foo(), TestEnum::B as i32); -/// class.set_foo(TestEnum::A); -/// assert_eq!(class.foo, TestEnum::A as i32); +/// class.set_foo(TestEnum::A as i32); +/// assert_eq!(class.foo, TestEnum::A); /// # } /// ``` #[proc_macro_derive(Property)] diff --git a/itest/rust/src/property_test.rs b/itest/rust/src/property_test.rs index cab166b12..710c338bb 100644 --- a/itest/rust/src/property_test.rs +++ b/itest/rust/src/property_test.rs @@ -321,7 +321,7 @@ fn derive_property() { } #[derive(GodotClass)] -#[class( base = Object)] +#[class(base = Object)] pub struct DeriveExport { #[export] pub foo: TestEnum,