Result for C++ an implementation of Rust's Enum type
Result. This C++ implementation
tries to be as close to the original thing as possible. Of course, it won't be because of the
language difference between the two.
or_()in this implementation because
orare keywords in C++.
- To create an Err
Resultuse the static member
- A panic is a
expect()do not display the error value or the okay value when they panic. This is because it might not be possible to convert the type into a string.
The ability to check for equality between a
Result and a value was added. However, one problem
arose when this feature was added. If the template types are the same
Result<int, int> or
Result<std::string, std::string>) then a compiler
error will be displayed if equality checking is used. This bug will have to be fixed in the near future. Anyone wanting to help with this issue, please work on the template branch. Your help will be appreciated.
This library contains a header and a source file. Just include the header and add the source file to your list of files to build. Result for C++ uses some C++ 17 library features so you will need a compiler that supports C++ 17.
clang++ -o program main.cpp other_file.cpp -std=c++17
#include "result.hpp" ...
Currently, no documentation exist at the moment. The best source of documentation is at the Rust STD Documentation website.