[ox] Cleanup String/StringView conversions, MallocaPtr
This commit is contained in:
12
deps/ox/src/ox/std/error.hpp
vendored
12
deps/ox/src/ox/std/error.hpp
vendored
@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user