file
ResultDef.hThis module provides macro definitions for implementing and working with CnxResult(T)
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Defines
- #define CnxResult(T)
- Macro Alias used to refer to an instantiation of
CnxResult(T)
for typeT
- #define CnxResultIdentifier(T, Identifier)
- Macro to create and refer to an identifier (function, variable, struct) related to an instantiation of
CnxResult(T)
of typeT
- #define Ok(T, value)
- Creates a
CnxResult(T)
holding the given value. - #define Err(T, error)
- Creates a
CnxResult(T)
holding the given error. - #define cnx_result_is_ok(self)
- Returns whether this
CnxResult(T)
is holding a value. - #define cnx_result_is_err(self)
- Returns whether this
CnxResult(T)
is holding an error. - #define cnx_result_as_const(self)
- Returns a const reference to the value stored in this
CnxResult(T)
- #define cnx_result_as_mut(self)
- Returns a reference to the value stored in this
CnxResult(T)
- #define cnx_result_unwrap(self)
- Returns the value stored in this
CnxResult(T)
- #define cnx_result_unwrap_or(self, default_value)
- Returns the value stored in this
CnxResult(T)
, ordefault_value
- #define cnx_result_unwrap_or_else(self, default_generator)
- Returns the value stored in this
CnxResult(T)
, ordefault_generator()
- #define cnx_result_expect(self, panic_message)
- Returns the value stored in this
CnxResult(T)
- #define cnx_result_unwrap_err(self)
- Returns the error stored in this
CnxResult(T)
- #define cnx_result_map(self, MapType, map_func)
- Maps the value stored in this
CnxResult(T)
- #define cnx_result_map_or(self, map_func, default_value)
- Maps the value stored in this
CnxResult(T)
- #define cnx_result_map_or_else(self, map_func, default_generator)
- Maps the value stored in this
CnxResult(T)
- #define cnx_result_map_err(self, map_func)
- Maps the error stored in this
CnxResult(T)
- #define cnx_result_and(self, result_b)
- Returns
result_b
isself
isOk
. Otherwise returns theErr
value ofself
. - #define cnx_result_and_then(self, next_func)
- Returns the result of calling
next_func
with the contained value ifself
isOk
. Otherwise, returns theErr
value contained inself
- #define cnx_result_or(self, result_b)
- Returns
self
if it isOk
, otherwise returnsresult_b
- #define cnx_result_or_else(self, func)
- Returns
self
if it isOk
, otherwise returns the result of callingfunc
- #define cnx_result_as_bool(self)
- Converts this
CnxResult(T)
to abool