Show / Hide Table of Contents

Class BoolExtensions

Provides extension methods for boolean values.

Inheritance
object
BoolExtensions
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: RustyOptions
Assembly: RustyOptions.dll
Syntax
public static class BoolExtensions

Methods

| Edit this page View Source

ThenSome<T>(bool, T)

Creates an Option<T> with a value if the boolean condition is true, otherwise returns the default value.

Declaration
public static Option<T> ThenSome<T>(this bool self, T value) where T : notnull
Parameters
Type Name Description
bool self

The boolean condition.

T value

The value to be wrapped in the option.

Returns
Type Description
Option<T>

An Option<T> with the specified value if the condition is true, otherwise the default value.

Type Parameters
Name Description
T

The type of the value.

| Edit this page View Source

Then<T>(bool, Func<T>)

Executes a function if the boolean value is true and returns an option.

Declaration
public static Option<T> Then<T>(this bool self, Func<T> thenFunc) where T : notnull
Parameters
Type Name Description
bool self

The boolean value.

Func<T> thenFunc

The function to execute if the boolean value is true.

Returns
Type Description
Option<T>

An option containing the result of the function if the boolean value is true, otherwise the default option value.

Type Parameters
Name Description
T

The type of the option value.

  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX