File tree 1 file changed +13
-1
lines changed 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -25,11 +25,23 @@ pub fn u32_to_usize(i: u32) -> usize {
25
25
unsafe { i. try_into ( ) . unwrap_unchecked ( ) }
26
26
}
27
27
28
- /// Converts a rust -bool into a sys-bool.
28
+ /// Converts a Rust -bool into a sys-bool.
29
29
pub const fn bool_to_sys ( value : bool ) -> sys:: GDExtensionBool {
30
30
value as sys:: GDExtensionBool
31
31
}
32
32
33
+ /// Converts a sys-bool to Rust-bool.
34
+ ///
35
+ /// # Panics
36
+ /// If the value is not a valid sys-bool (0 or 1).
37
+ pub fn bool_from_sys ( value : sys:: GDExtensionBool ) -> bool {
38
+ match value {
39
+ SYS_TRUE => true ,
40
+ SYS_FALSE => false ,
41
+ _ => panic ! ( "Invalid GDExtensionBool value: {}" , value) ,
42
+ }
43
+ }
44
+
33
45
/// Convert a list into a pointer + length pair. Should be used together with [`ptr_list_from_sys`].
34
46
///
35
47
/// If `list_from_sys` is not called on this list then that will cause a memory leak.
You can’t perform that action at this time.
0 commit comments