Skip to content

Commit

Permalink
ci fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
patataofcourse committed Aug 4, 2023
1 parent c92409e commit 64468b2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
12 changes: 7 additions & 5 deletions godot-macros/src/derive_export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ pub fn transform(decl: Declaration) -> ParseResult<TokenStream2> {
_ => 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"
Expand All @@ -43,7 +42,10 @@ pub fn transform(decl: Declaration) -> ParseResult<TokenStream2> {
"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}"));

Expand All @@ -57,8 +59,8 @@ pub fn transform(decl: Declaration) -> ParseResult<TokenStream2> {
}
};
}
hint_string = hint_string_segments.join(",");
}
hint_string_segments.join(",")
};

let out = quote! {
#[allow(unused_parens)]
Expand Down
12 changes: 8 additions & 4 deletions godot-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion itest/rust/src/property_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ fn derive_property() {
}

#[derive(GodotClass)]
#[class( base = Object)]
#[class(base = Object)]
pub struct DeriveExport {
#[export]
pub foo: TestEnum,
Expand Down

0 comments on commit 64468b2

Please sign in to comment.