[ox] Cleanup String/StringView conversions, MallocaPtr

This commit is contained in:
2023-11-23 01:34:16 -06:00
parent 5b91ad25c2
commit a84a829769
17 changed files with 66 additions and 48 deletions

View File

@ -25,8 +25,6 @@ class exception {
#endif
#include "def.hpp"
#include "defines.hpp"
#include "strongint.hpp"
#include "typetraits.hpp"
#include "utility.hpp"
@ -191,6 +189,13 @@ struct [[nodiscard]] Result {
return value;
}
constexpr auto &unwrapThrow() {
if (error) {
throw ox::Exception(error);
}
return value;
}
constexpr const auto &unwrap() const noexcept {
if (error) [[unlikely]] {
oxPanic(error, "Failed unwrap");
@ -198,7 +203,8 @@ struct [[nodiscard]] Result {
return value;
}
constexpr ox::Result<T> to(const auto &f) noexcept {
template<typename U = T>
constexpr ox::Result<U> to(const auto &f) noexcept {
if (error) [[unlikely]] {
return OxError(1);
}