mirror of
https://github.com/arcan1s/result.git
synced 2025-04-25 07:57:17 +00:00
update README
This commit is contained in:
parent
f73aa9ca16
commit
e03dc8efb0
Binary file not shown.
17
README.md
17
README.md
@ -76,3 +76,20 @@ int main()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### `Result::match` function
|
||||||
|
|
||||||
|
Alternatively you can use tempalte function to do result match, e.g.:
|
||||||
|
|
||||||
|
```cpp
|
||||||
|
template <class T> Result::Content print_example(IResult<T> r)
|
||||||
|
{
|
||||||
|
Result::match(r, [](const T &value) {
|
||||||
|
std::cout << "Result has value " << value << std::endl;
|
||||||
|
}, [](const IError &error) {
|
||||||
|
std::cout << "Result has error " << error.message() << std::endl;
|
||||||
|
});
|
||||||
|
|
||||||
|
return r.type();
|
||||||
|
}
|
||||||
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user