refactor(result): add print operator to result

Fixes #6
This commit is contained in:
2026-06-03 16:06:59 +02:00
parent 1b9514c49c
commit ab6b65a70e
2 changed files with 23 additions and 0 deletions
+11
View File
@@ -359,6 +359,17 @@ struct token_error {
* @return true if the errors are not equal.
*/
bool operator!=(const token_error& rhs) const { return !this->operator==(rhs); }
/**
* @brief Prints a token error to an output stream.
*
* @param os Output stream.
* @param error Token error to print.
* @return The output stream.
*/
friend std::ostream& operator<<(std::ostream& os, const token_error& error) {
return os << error.location << ": error: unknown";
}
};
using token_r = furlang::result<token, token_error>; /**< Alias to a token result. */