Class NumericOption
This class contains static methods for creation an Option<T>.
Inherited Members
Namespace: RustyOptions
Assembly: RustyOptions.dll
Syntax
public static class NumericOption
Methods
| Edit this page View SourceCreate<T>(T?)
Returns a Some
option for the specified value
is it is not null, otherwise None
.
Declaration
public static NumericOption<T> Create<T>(T? value) where T : struct, INumber<T>
Parameters
Type | Name | Description |
---|---|---|
T? | value | The value to wrap in a |
Returns
Type | Description |
---|---|
NumericOption<T> | The given value, wrapped in a |
Type Parameters
Name | Description |
---|---|
T |
None<T>()
Returns the None
option for the specified T
.
Declaration
public static NumericOption<T> None<T>() where T : struct, INumber<T>
Returns
Type | Description |
---|---|
NumericOption<T> |
Type Parameters
Name | Description |
---|---|
T |
Parse<T>(ReadOnlySpan<char>)
Parses a char span into any type that supports ISpanParsable<TSelf>.
Declaration
public static NumericOption<T> Parse<T>(ReadOnlySpan<char> s) where T : struct, ISpanParsable<T>, INumber<T>
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<char> | s | The char span to parse. |
Returns
Type | Description |
---|---|
NumericOption<T> | The parsed value wrapped in a |
Type Parameters
Name | Description |
---|---|
T | The type to parse the char span into. |
Parse<T>(ReadOnlySpan<char>, IFormatProvider?)
Parses a char span into any type that supports ISpanParsable<TSelf>.
Declaration
public static NumericOption<T> Parse<T>(ReadOnlySpan<char> s, IFormatProvider? provider) where T : struct, ISpanParsable<T>, INumber<T>
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<char> | s | The char span to parse. |
IFormatProvider | provider | An optional format provider. |
Returns
Type | Description |
---|---|
NumericOption<T> | The parsed value wrapped in a |
Type Parameters
Name | Description |
---|---|
T | The type to parse the char span into. |
Parse<T>(string)
Parses a string into any type that supports IParsable<TSelf>.
Declaration
public static NumericOption<T> Parse<T>(string s) where T : struct, IParsable<T>, INumber<T>
Parameters
Type | Name | Description |
---|---|---|
string | s | The string to parse. |
Returns
Type | Description |
---|---|
NumericOption<T> | The parsed value wrapped in a |
Type Parameters
Name | Description |
---|---|
T | The type to parse the string into. |
Parse<T>(string, IFormatProvider?)
Parses a string into any type that supports IParsable<TSelf>.
Declaration
public static NumericOption<T> Parse<T>(string s, IFormatProvider? provider) where T : struct, IParsable<T>, INumber<T>
Parameters
Type | Name | Description |
---|---|---|
string | s | The string to parse. |
IFormatProvider | provider | An optional format provider. |
Returns
Type | Description |
---|---|
NumericOption<T> | The parsed value wrapped in a |
Type Parameters
Name | Description |
---|---|
T | The type to parse the string into. |
Some<T>(T)
Returns a Some
option for the specified value
.
Declaration
public static NumericOption<T> Some<T>(T value) where T : struct, INumber<T>
Parameters
Type | Name | Description |
---|---|---|
T | value | The value to wrap in a |
Returns
Type | Description |
---|---|
NumericOption<T> | The given value, wrapped in a |
Type Parameters
Name | Description |
---|---|
T |