File tree 3 files changed +16
-10
lines changed 3 files changed +16
-10
lines changed Original file line number Diff line number Diff line change @@ -25,8 +25,7 @@ pub fn transform(decl: Declaration) -> ParseResult<TokenStream2> {
25
25
_ => unreachable ! ( ) ,
26
26
} ;
27
27
28
- let hint_string;
29
- if enum_. variants . is_empty ( ) {
28
+ let hint_string = if enum_. variants . is_empty ( ) {
30
29
return bail ! (
31
30
enum_. name,
32
31
"In order to derive Export, enums must have at least one variant"
@@ -43,7 +42,10 @@ pub fn transform(decl: Declaration) -> ParseResult<TokenStream2> {
43
42
"Property can only be derived on enums with explicit discriminants in all their variants"
44
43
) ;
45
44
} ;
46
- let v_disc_trimmed = v_disc. to_string ( ) . trim_matches ( [ '(' , ')' ] . as_slice ( ) ) . to_string ( ) ;
45
+ let v_disc_trimmed = v_disc
46
+ . to_string ( )
47
+ . trim_matches ( [ '(' , ')' ] . as_slice ( ) )
48
+ . to_string ( ) ;
47
49
48
50
hint_string_segments. push ( format ! ( "{v_name}:{v_disc_trimmed}" ) ) ;
49
51
@@ -57,8 +59,8 @@ pub fn transform(decl: Declaration) -> ParseResult<TokenStream2> {
57
59
}
58
60
} ;
59
61
}
60
- hint_string = hint_string_segments. join ( "," ) ;
61
- }
62
+ hint_string_segments. join ( "," )
63
+ } ;
62
64
63
65
let out = quote ! {
64
66
#[ allow( unused_parens) ]
Original file line number Diff line number Diff line change @@ -470,7 +470,8 @@ pub fn derive_from_variant(input: TokenStream) -> TokenStream {
470
470
/// ```no_run
471
471
/// # use godot::prelude::*;
472
472
/// #[repr(i32)]
473
- /// #[derive(Debug, Property)]
473
+ /// #[derive(Property)]
474
+ /// # #[derive(PartialEq, Eq, Debug)]
474
475
/// enum TestEnum {
475
476
/// A = 0,
476
477
/// B = 1,
@@ -482,11 +483,14 @@ pub fn derive_from_variant(input: TokenStream) -> TokenStream {
482
483
/// foo: TestEnum
483
484
/// }
484
485
///
486
+ /// # #[godot_api]
487
+ /// # impl TestClass {}
488
+ ///
485
489
/// # fn main() {
486
- /// let mut class = TestClass {foo: TestEnum::B}.get_foo() ;
490
+ /// let mut class = TestClass {foo: TestEnum::B};
487
491
/// assert_eq!(class.get_foo(), TestEnum::B as i32);
488
- /// class.set_foo(TestEnum::A);
489
- /// assert_eq!(class.foo, TestEnum::A as i32 );
492
+ /// class.set_foo(TestEnum::A as i32 );
493
+ /// assert_eq!(class.foo, TestEnum::A);
490
494
/// # }
491
495
/// ```
492
496
#[ proc_macro_derive( Property ) ]
Original file line number Diff line number Diff line change @@ -321,7 +321,7 @@ fn derive_property() {
321
321
}
322
322
323
323
#[ derive( GodotClass ) ]
324
- #[ class( base = Object ) ]
324
+ #[ class( base = Object ) ]
325
325
pub struct DeriveExport {
326
326
#[ export]
327
327
pub foo : TestEnum ,
You can’t perform that action at this time.
0 commit comments