This commit is contained in:
Able 2021-11-05 08:43:53 -05:00
parent 79c2b417c2
commit 2150f796a7

4
rust.h
View file

@ -17,14 +17,12 @@
#define Result_impl(T, E) \ #define Result_impl(T, E) \
typedef struct { \ typedef struct { \
bool is_valid; \ bool is_valid; \
union { \ enum { \
T data; \ T data; \
E err; \ E err; \
}; \ }; \
} Result_##T##_##E; } Result_##T##_##E;
#define Result(T, E) Result_##T##_##E #define Result(T, E) Result_##T##_##E
#define Result_unwrap_impl(T, E) \ #define Result_unwrap_impl(T, E) \
T Result_##T##_unwrap (Result(T, E) result) { \ T Result_##T##_unwrap (Result(T, E) result) { \
if (result.is_valid) \ if (result.is_valid) \