file
OptionDef.hThis module provides macro definitions for implementing and working with CnxOption(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 CnxOption(T)
- Macro alias for
CnxOption
holding the typeT
- #define CnxOptionIdentifier(T, Identifier)
- Creates an identifier for a function, variable, or struct associated with
CnxOption(T)
- #define Some(T, value)
- Creates a
CnxOption(T)
holding the given value. - #define None(T)
- Creates a
CnxOption(T)
holding no value. - #define cnx_option_is_some(self)
- Returns whether this
CnxOption(T)
is holding a value. - #define cnx_option_is_none(self)
- Returns whether this
CnxOption(T)
isn't holding a value. - #define cnx_option_as_const(self)
- Returns a const reference to the value stored in this
CnxOption(T)
- #define cnx_option_as_mut(self)
- Returns a reference to the value stored in this
CnxOption(T)
- #define cnx_option_unwrap(self)
- Returns the value stored in this
CnxOption(T)
- #define cnx_option_unwrap_or(self, default_value)
- Returns the value stored in this
CnxOption(T)
, ordefault_value
if this isNone(T)
- #define cnx_option_unwrap_or_else(self, default_generator)
- Returns the value stored in this
CnxOption(T)
, or the value returned bydefault_generator
if this isNone(T)
- #define cnx_option_expect(self, panic_message)
- Returns the value stored in this
CnxOption(T)
- #define cnx_option_map(self, MapType, map_func)
- Maps the value stored in this
CnxOption(T)
- #define cnx_option_map_or(self, map_func, default_value)
- Maps the value stored in this
CnxOption(T)
- #define cnx_option_map_or_else(self, map_func, default_generator)
- Maps the value stored in this
CnxOption(T)
- #define cnx_option_and(self, option_b)
- Returns
option_b
ifself
isSome
. Otherwise, returnsNone
- #define cnx_option_and_then(self, next_func)
- Returns the result of calling
next_func
with the contained value if this isSome
, otherwise returnsNone
. - #define cnx_option_or(self, option_b)
- Returns
self
if it isSome
, otherwise returnsoption_b
- #define cnx_option_or_else(self, func)
- Returns
self
if it isSome
, otherwise returns the result of callingfunc
- #define cnx_option_as_bool(self)
- Converts the given
CnxOption(T)
to abool