Skip to content

Commit 6995316

Browse files
Adjusted types
1 parent ffdd692 commit 6995316

File tree

1 file changed

+33
-33
lines changed

1 file changed

+33
-33
lines changed

json_types.h

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -20,46 +20,46 @@
2020
typed(json_boolean) is_ok; \
2121
union { \
2222
typed(name) value; \
23-
const char *err; \
23+
typed(json_string) err; \
2424
} inner; \
2525
} result(name); \
2626
result(name) result_ok(name)(typed(name)); \
27-
result(name) result_err(name)(const char *); \
27+
result(name) result_err(name)(typed(json_string)); \
2828
typed(json_boolean) result_is_ok(name)(result(name) *); \
2929
typed(json_boolean) result_is_err(name)(result(name) *); \
3030
typed(name) result_unwrap(name)(result(name) *); \
31-
const char *result_unwrap_err(name)(result(name) *);
31+
typed(json_string) result_unwrap_err(name)(result(name) *);
3232

33-
#define define_result_type(name) \
34-
result(name) result_ok(name)(typed(name) value) { \
35-
result(name) retval = { \
36-
.is_ok = true, \
37-
.inner = { \
38-
.value = value, \
39-
}, \
40-
}; \
41-
return retval; \
42-
} \
43-
result(name) result_err(name)(const char *err) { \
44-
result(name) retval = { \
45-
.is_ok = false, \
46-
.inner = { \
47-
.err = err, \
48-
}, \
49-
}; \
50-
return retval; \
51-
} \
52-
json_boolean_t result_is_ok(name)(result(name) * result) { \
53-
return result->is_ok; \
54-
} \
55-
json_boolean_t result_is_err(name)(result(name) * result) { \
56-
return !result->is_ok; \
57-
} \
58-
typed(name) result_unwrap(name)(result(name) * result) { \
59-
return result->inner.value; \
60-
} \
61-
const char *result_unwrap_err(name)(result(name) * result) { \
62-
return result->inner.err; \
33+
#define define_result_type(name) \
34+
result(name) result_ok(name)(typed(name) value) { \
35+
result(name) retval = { \
36+
.is_ok = true, \
37+
.inner = { \
38+
.value = value, \
39+
}, \
40+
}; \
41+
return retval; \
42+
} \
43+
result(name) result_err(name)(typed(json_string) err) { \
44+
result(name) retval = { \
45+
.is_ok = false, \
46+
.inner = { \
47+
.err = err, \
48+
}, \
49+
}; \
50+
return retval; \
51+
} \
52+
typed(json_boolean) result_is_ok(name)(result(name) * result) { \
53+
return result->is_ok; \
54+
} \
55+
typed(json_boolean) result_is_err(name)(result(name) * result) { \
56+
return !result->is_ok; \
57+
} \
58+
typed(name) result_unwrap(name)(result(name) * result) { \
59+
return result->inner.value; \
60+
} \
61+
typed(json_string) result_unwrap_err(name)(result(name) * result) { \
62+
return result->inner.err; \
6363
}
6464

6565
#ifndef __cplusplus

0 commit comments

Comments
 (0)