changed Result struct fields

This commit is contained in:
Timerix 2025-07-22 23:57:31 +03:00
parent 447c15bc46
commit a9fa42c23f

View File

@ -30,10 +30,10 @@ void Error_printAndExit(Error* e) __attribute__ ((__noreturn__));
typedef struct Result_ { typedef struct Result_ {
Error* error; Error* error;
union { union {
u64 v_u64; u64 u;
i64 v_i64; i64 i;
f32 v_f32; f32 f;
f64 v_f64; f64 d;
void* v_ptr; void* v_ptr;
}; };
} Result_; } 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_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_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) \ #define try(VAR, RSLT_CALL, DEFER_CODE) \
Result_ VAR = RSLT_CALL;\ Result_ VAR = RSLT_CALL;\