class Result
Declaration
template <class T, class E>
class Result { /* full declaration omitted */ };
Declared at: sus/result/result.h:81
Templates
- T
- E
Method Overview
- public constexpr Result<T, E>(const int & t) noexcept
- public constexpr Result<T, E>(int && t) noexcept
- public template <class U>constexpr Result<T, E>(U && t) noexcept
- public inline constexpr Result<T, E>(sus::result::Result::WithOk) noexcept
- public constexpr Result<T, E>(sus::result::OkVoid) noexcept
- public Result<T, E>(const Result<T, E> &)
- public Result<T, E>(const Result<T, E> &)
- public Result<T, E>(Result<T, E> &&)
- public Result<T, E>(Result<T, E> &&)
- public constexpr const E & as_err() &&
- public constexpr const E & as_err() const &
- public constexpr int & as_value_mut() &
- public constexpr Result<T, E> clone() const & noexcept
- public constexpr void clone_from(const Result<T, E> & source) &
- public inline constexpr T expect(const char * msg) && noexcept
- public constexpr ::sus::option::OptionIter<T> into_iter() && noexcept
- public constexpr int iter() const & noexcept
- public constexpr int iter() && noexcept
- public constexpr int iter_mut() && noexcept
- public constexpr int iter_mut() & noexcept
- public inline constexpr T unwrap() && noexcept
- public inline constexpr E unwrap_err() && noexcept
- public inline constexpr E unwrap_err_unchecked(::sus::marker::UnsafeFnMarker) && noexcept
- public constexpr T unwrap_or_default() && noexcept
- public template <class op:auto>constexpr T unwrap_or_else(::sus::fn::FnOnce<T (E &&)> auto op) && noexcept
- public inline constexpr T unwrap_unchecked(::sus::marker::UnsafeFnMarker) && noexcept
- public static inline constexpr Result<T, E> with_err(E && e) noexcept
- public static inline constexpr Result<T, E> with_err(const E & e) noexcept
- public ~Result<T, E>()
Methods
¶constexpr Result<T, E>(const int& t) noexcept
constexpr Result<T, E>(const int& t) noexcept
Declared at: sus/result/result.h:118
Parameters
- const int& t
¶constexpr Result<T, E>(int&& t) noexcept
constexpr Result<T, E>(int&& t) noexcept
Declared at: sus/result/result.h:124
Parameters
- int&& t
¶template <class U>
constexpr Result<T, E>(U&& t) noexcept
template <class U>
constexpr Result<T, E>(U&& t) noexcept
Description
#[doc.overloads=ctor.ok]
Declared at: sus/result/result.h:131
Templates
- U
Parameters
- U&& t
¶inline constexpr Result<T, E>(
sus::result::Result::WithOk) noexcept
inline constexpr Result<T, E>(
sus::result::Result::WithOk) noexcept
Declared at: sus/result/result.h:912
Parameters
- sus::result::Result::WithOk
¶constexpr Result<T, E>(
sus::result::OkVoid) noexcept
constexpr Result<T, E>(
sus::result::OkVoid) noexcept
Description
Construct an Result that is holding the given success value. # Const References For `Result <const T & , E>` it is possible to bind to a temporary which would create a memory safety bug. The `[[clang::lifetimebound]]` attribute is used to prevent this via Clang. But additionally, the incoming type is required to match with `sus::construct::SafelyConstructibleFromReference` to prevent conversions that would construct a temporary. To force accepting a const reference anyway in cases where a type can convert to a reference without constructing a temporary, use an unsafe `static_cast <const T & >()` at the callsite (and document it =)). #[doc.overloads=ctor.ok]
Declared at: sus/result/result.h:114
Parameters
¶Result<T, E>(const Result<T, E>&)
Result<T, E>(const Result<T, E>&)
Description
Copy constructor for `Result <T , E>` which satisfies [`sus::mem::Copy <Result <T , E>>`](sus-mem-Copy.html) if [`Copy <T >`](sus-mem-Copy.html) and [`Copy <E >`](sus-mem-Copy.html) are satisfied. If `T` and `E` can be trivially copy-constructed, then `Result <T , E>` can also be trivially copy-constructed. #[doc.overloads=copy]
Declared at: sus/result/result.h:166
Parameters
- const Result<T, E>&
¶Result<T, E>(const Result<T, E>&)
Result<T, E>(const Result<T, E>&)
Description
Copy constructor for `Result <T , E>` which satisfies [`sus::mem::Copy <Result <T , E>>`](sus-mem-Copy.html) if [`Copy <T >`](sus-mem-Copy.html) and [`Copy <E >`](sus-mem-Copy.html) are satisfied. If `T` and `E` can be trivially copy-constructed, then `Result <T , E>` can also be trivially copy-constructed. #[doc.overloads=copy]
Declared at: sus/result/result.h:166
Parameters
- const Result<T, E>&
¶Result<T, E>(Result<T, E>&&)
Result<T, E>(Result<T, E>&&)
Description
Move constructor for `Result <T , E>` which satisfies [`Move`]($sus::mem::Move), if `T` and `E` both satisfy [`Move`]($sus::mem::Move). If `T` and `E` can be trivially move-constructed, then `Result <T , E>` can also be trivially move-constructed. When trivially-moved, the `Result` is copied on move, and the moved-from `Result` is unchanged but should still not be used thereafter without reinitializing it. #[doc.overloads=move]
Declared at: sus/result/result.h:203
Parameters
- Result<T, E>&&
¶Result<T, E>(Result<T, E>&&)
Result<T, E>(Result<T, E>&&)
Description
Move constructor for `Result <T , E>` which satisfies [`Move`]($sus::mem::Move), if `T` and `E` both satisfy [`Move`]($sus::mem::Move). If `T` and `E` can be trivially move-constructed, then `Result <T , E>` can also be trivially move-constructed. When trivially-moved, the `Result` is copied on move, and the moved-from `Result` is unchanged but should still not be used thereafter without reinitializing it. #[doc.overloads=move]
Declared at: sus/result/result.h:203
Parameters
- Result<T, E>&&
¶constexpr const E& as_err() &&
constexpr const E& as_err() &&
Declared at: sus/result/result.h:544
¶constexpr const E& as_err() const&
constexpr const E& as_err() const&
Description
Returns a const reference to the contained `Err` value. # Panics Panics if the value is an `Ok` or the Result is moved from.
Declared at: sus/result/result.h:529
¶constexpr int& as_value_mut() &
constexpr int& as_value_mut() &
Declared at: sus/result/result.h:510
¶constexpr Result<T, E> clone() const& noexcept
constexpr Result<T, E> clone() const& noexcept
Declared at: sus/result/result.h:231
¶constexpr void clone_from(
const Result<T, E>& source) &
constexpr void clone_from(
const Result<T, E>& source) &
Declared at: sus/result/result.h:248
Parameters
- const Result<T, E>& source
¶inline constexpr T expect(
const char* msg) && noexcept
inline constexpr T expect(
const char* msg) && noexcept
Description
Returns the contained `Ok` value, consuming the self value. Because this function may panic, its use is generally discouraged. Instead, prefer to use pattern matching and handle the `Err` case explicitly, or call `unwrap_or`, `unwrap_or_else`, or `unwrap_or_default`. # Panics Panics if the value is an Err, with a panic message including the passed message, and the content of the Err.
Declared at: sus/result/result.h:578
Parameters
- const char* msg
¶constexpr ::sus::option::OptionIter<T>
into_iter() && noexcept
constexpr ::sus::option::OptionIter<T>
into_iter() && noexcept
Declared at: sus/result/result.h:751
¶constexpr int iter() const& noexcept
constexpr int iter() const& noexcept
Declared at: sus/result/result.h:692
¶constexpr int iter() && noexcept
constexpr int iter() && noexcept
Declared at: sus/result/result.h:708
¶constexpr int iter_mut() && noexcept
constexpr int iter_mut() && noexcept
Declared at: sus/result/result.h:736
¶constexpr int iter_mut() & noexcept
constexpr int iter_mut() & noexcept
Declared at: sus/result/result.h:724
¶inline constexpr T unwrap() && noexcept
inline constexpr T unwrap() && noexcept
Description
Returns the contained `Ok` value, consuming the self value. Because this function may panic, its use is generally discouraged. Instead, prefer to use pattern matching and handle the `Err` case explicitly, or call `unwrap_or()`, `unwrap_or_else()`, or `unwrap_or_default()`. # Panics Panics if the value is an `Err` or the Result is moved from.
Declared at: sus/result/result.h:555
¶inline constexpr E unwrap_err() && noexcept
inline constexpr E unwrap_err() && noexcept
Description
Returns the contained `Err` value, consuming the self value. # Panics Panics if the value is an `Ok` or the Result is moved from.
Declared at: sus/result/result.h:636
¶inline constexpr E unwrap_err_unchecked(
::sus::marker::UnsafeFnMarker) && noexcept
inline constexpr E unwrap_err_unchecked(
::sus::marker::UnsafeFnMarker) && noexcept
Description
Returns the contained `Err` value, consuming the self value, without checking that the value is not an `Ok`. # Safety Calling this method on an `Ok` or a moved-from Result is Undefined Behavior.
Declared at: sus/result/result.h:658
Parameters
¶constexpr T unwrap_or_default() && noexcept
constexpr T unwrap_or_default() && noexcept
Description
Returns the contained Ok value or a default. Consumes the Result and, if it held an Ok value, the value is returned. Otherwise the default value of the Ok value's type is returned.
Declared at: sus/result/result.h:596
¶template <class op : auto>
constexpr T unwrap_or_else(
::sus::fn::FnOnce<T(E&&)> auto op) && noexcept
template <class op : auto>
constexpr T unwrap_or_else(
::sus::fn::FnOnce<T(E&&)> auto op) && noexcept
Declared at: sus/result/result.h:680
Templates
- op:auto
Parameters
- ::sus::fn::FnOnce<T(E&&)> auto op
¶inline constexpr T unwrap_unchecked(
::sus::marker::UnsafeFnMarker) && noexcept
inline constexpr T unwrap_unchecked(
::sus::marker::UnsafeFnMarker) && noexcept
Description
Returns the contained `Ok` value, consuming the self value, without checking that the value is not an `Err`. # Safety Calling this method on an `Err` or a moved-from Result is Undefined Behavior.
Declared at: sus/result/result.h:619
Parameters
¶static inline constexpr Result<T, E> with_err(
E&& e) noexcept
static inline constexpr Result<T, E> with_err(
E&& e) noexcept
Declared at: sus/result/result.h:143
Parameters
- E&& e
¶static inline constexpr Result<T, E> with_err(
const E& e) noexcept
static inline constexpr Result<T, E> with_err(
const E& e) noexcept
Description
Construct an Result that is holding the given error value.
Declared at: sus/result/result.h:138
Parameters
- const E& e
¶~Result<T, E>()
~Result<T, E>()
Description
Destructor for the `Result`. Destroys the Ok or Err value contained within the `Result`. If T and E can be trivially destroyed, `Result <T , E>` can also be trivially destroyed.
Declared at: sus/result/result.h:155