4040 variable = std::move(GEODE_CONCAT(res, __LINE__)).unwrap()
4141 #endif
4242
43+ #if !defined(GEODE_LET_OK)
44+ #define GEODE_LET_OK (variable, ...) \
45+ auto [variable, GEODE_CONCAT(res, __LINE__)] = \
46+ std::make_pair (geode::impl::ResultOkType<decltype (__VA_ARGS__)>{}, (__VA_ARGS__)); \
47+ GEODE_CONCAT (res, __LINE__).isOk() && \
48+ (variable = std::move(GEODE_CONCAT(res, __LINE__)).unwrap(), true)
49+ #endif
50+
51+ #if !defined(GEODE_LET_ERR)
52+ #define GEODE_LET_ERR (variable, ...) \
53+ auto [variable, GEODE_CONCAT(res, __LINE__)] = \
54+ std::make_pair (geode::impl::ResultErrType<decltype (__VA_ARGS__)>{}, (__VA_ARGS__)); \
55+ GEODE_CONCAT (res, __LINE__).isErr() && \
56+ (variable = std::move(GEODE_CONCAT(res, __LINE__)).unwrapErr(), true)
57+ #endif
58+
59+ #if !defined(GEODE_LET_SOME)
60+ #define GEODE_LET_SOME (variable, ...) \
61+ auto [variable, GEODE_CONCAT(res, __LINE__)] = \
62+ std::make_pair (geode::impl::OptionalType<decltype (__VA_ARGS__)>{}, (__VA_ARGS__)); \
63+ GEODE_CONCAT (res, __LINE__).has_value() && \
64+ (variable = std::move(GEODE_CONCAT(res, __LINE__)).value(), true)
65+ #endif
66+
4367namespace geode {
4468 template <class OkType , class ErrType >
4569 class Result ;
@@ -556,7 +580,8 @@ namespace geode {
556580 }
557581 }
558582
559- // / @brief Unwraps the Ok value from the Result, returning the result of an operation if unavailable
583+ // / @brief Unwraps the Ok value from the Result, returning the result of an
584+ // / operation if unavailable
560585 // / @param operation the operation to perform if the Result is Err
561586 // / @return the Ok value if available, otherwise the result of the operation
562587 constexpr OkType unwrapOrElse (std::invocable auto && operation
@@ -571,7 +596,8 @@ namespace geode {
571596 }
572597 }
573598
574- // / @brief Unwraps the Ok value from the Result, returning the result of an operation if unavailable
599+ // / @brief Unwraps the Ok value from the Result, returning the result of an
600+ // / operation if unavailable
575601 // / @param operation the operation to perform if the Result is Err
576602 // / @return the Ok value if available, otherwise the result of the operation
577603 constexpr OkType unwrapOrElse (std::invocable auto && operation
@@ -918,7 +944,8 @@ namespace geode {
918944 }
919945 }
920946
921- // / @brief Unwraps the Ok value from the Result, returning the result of an operation if unavailable
947+ // / @brief Unwraps the Ok value from the Result, returning the result of an
948+ // / operation if unavailable
922949 // / @param operation the operation to perform if the Result is Err
923950 // / @return the Ok value if available, otherwise the result of the operation
924951 constexpr OkType unwrapOrElse (std::invocable auto && operation
@@ -933,7 +960,8 @@ namespace geode {
933960 }
934961 }
935962
936- // / @brief Unwraps the Ok value from the Result, returning the result of an operation if unavailable
963+ // / @brief Unwraps the Ok value from the Result, returning the result of an
964+ // / operation if unavailable
937965 // / @param operation the operation to perform if the Result is Err
938966 // / @return the Ok value if available, otherwise the result of the operation
939967 constexpr OkType unwrapOrElse (std::invocable auto && operation
@@ -1775,7 +1803,8 @@ namespace geode {
17751803 }
17761804 }
17771805
1778- // / @brief Flattens the Result from Result<Result<OkType, ErrType>, ErrType> to Result<OkType, ErrType>
1806+ // / @brief Flattens the Result from Result<Result<OkType, ErrType>, ErrType> to
1807+ // / Result<OkType, ErrType>
17791808 // / @return the inner Result if the Result is Ok, otherwise the outer Result
17801809 constexpr Result<impl::ResultOkType<OkType>, ErrType> flatten (
17811810 ) && noexcept (std::is_nothrow_move_constructible_v<OkType> && std::is_nothrow_move_constructible_v<ErrType>)
@@ -1789,7 +1818,8 @@ namespace geode {
17891818 }
17901819 }
17911820
1792- // / @brief Flattens the Result from Result<Result<OkType, ErrType>, ErrType> to Result<OkType, ErrType>
1821+ // / @brief Flattens the Result from Result<Result<OkType, ErrType>, ErrType> to
1822+ // / Result<OkType, ErrType>
17931823 // / @return the inner Result if the Result is Ok, otherwise the outer Result
17941824 constexpr Result<impl::ResultOkType<OkType>, ErrType> flatten (
17951825 ) const & noexcept (std::is_nothrow_move_constructible_v<OkType> && std::is_nothrow_move_constructible_v<ErrType>)
0 commit comments