Compare commits

..

1 Commits

Author SHA1 Message Date
a9fa42c23f changed Result struct fields 2025-07-22 23:57:31 +03:00

View File

@@ -30,10 +30,10 @@ void Error_printAndExit(Error* e) __attribute__ ((__noreturn__));
typedef struct Result_ {
Error* error;
union {
u64 v_u64;
i64 v_i64;
f32 v_f32;
f64 v_f64;
u64 u;
i64 i;
f32 f;
f64 d;
void* v_ptr;
};
} Result_;
@@ -43,7 +43,7 @@ typedef struct Result_ {
#define RESULT_ERROR(MSG, IS_MSG_ON_HEAP) (Result_){ .error = Error_create(MSG, IS_MSG_ON_HEAP, ErrorCallPos_here()) }
#define RESULT_VOID (Result_){ .error = NULL }
#define RESULT_VALUE(TYPE, V) (Result_){ .error = NULL, .v_##TYPE = V }
#define RESULT_VALUE(FIELD, V) (Result_){ .error = NULL, .FIELD = V }
#define try(VAR, RSLT_CALL, DEFER_CODE) \
Result_ VAR = RSLT_CALL;\