File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change 88 * Snake case methods renamed to camel case
99* Universal ` GEODE_UNWRAP(res) ` and ` GEODE_UNWRAP_INTO(value, res) ` macros
1010 * These macros were already previously available, but this is just a reminder that they can help a lot when dealing with results.
11+ ``` cpp
12+ Result<std::string> addValues (matjson::Value json) {
13+ // Value::asInt() returns a Result<int >
14+ GEODE_UNWRAP_INTO(int a, json[ "a"] .asInt());
15+ GEODE_UNWRAP_INTO(int b, json[ "b"] .asInt());
16+ // must wrap return value with Ok
17+ return Ok(fmt::format("sum is {}", a + b));
18+ }
19+ ```
1120 * If you only ever expect to build your code with ** clang** , you can use the ` GEODE_UNWRAP ` macro like so, for convenience:
1221 ```cpp
1322 Result<int > getInt();
You can’t perform that action at this time.
0 commit comments