using System;
namespace Barotrauma
{
///
/// Implementation of Option type.
///
///
/// Credit Jlobblet
///
public abstract class Option
{
public static Option Some(T value) => Some.Create(value);
public static Option None() => None.Create();
public bool IsNone() => this is None;
public bool IsSome() => this is Some;
public Option Select(Func selector) =>
this switch
{
Some { Value: var value } => Option.Some(selector.Invoke(value)),
None _ => Option.None(),
_ => throw new ArgumentOutOfRangeException()
};
}
}