[ox] Make Result copyTo and moveTo take refs
This commit is contained in:
30
deps/ox/src/ox/std/error.hpp
vendored
30
deps/ox/src/ox/std/error.hpp
vendored
@ -165,23 +165,39 @@ struct [[nodiscard]] Result {
|
||||
return error == 0;
|
||||
}
|
||||
|
||||
constexpr Error copyTo(type *val) const noexcept {
|
||||
constexpr Error copyTo(type &val) const & noexcept {
|
||||
if (!error) [[likely]] {
|
||||
*val = value;
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
constexpr Error copyTo(type &val) const && noexcept {
|
||||
if (!error) [[likely]] {
|
||||
*val = value;
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
constexpr Error copyTo(type &val) & noexcept {
|
||||
*val = value;
|
||||
return error;
|
||||
}
|
||||
|
||||
constexpr Error copyTo(type *val) noexcept {
|
||||
*val = value;
|
||||
return error;
|
||||
}
|
||||
|
||||
constexpr Error moveTo(type *val) noexcept {
|
||||
constexpr Error copyTo(type &val) && noexcept {
|
||||
if (!error) [[likely]] {
|
||||
*val = std::move(value);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
constexpr Error moveTo(type &val) noexcept {
|
||||
if (!error) [[likely]] {
|
||||
val = std::move(value);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
constexpr T &unwrap() & noexcept {
|
||||
if (error) {
|
||||
oxPanic(error, "Failed unwrap");
|
||||
|
Reference in New Issue
Block a user