From 3eba8b921dfa823302b215c671922a06eaebba23 Mon Sep 17 00:00:00 2001 From: Lala Sabathil Date: Wed, 20 Dec 2023 23:09:19 +0100 Subject: [PATCH] fix: optional --- DisCatSharp/Entities/Optional.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/DisCatSharp/Entities/Optional.cs b/DisCatSharp/Entities/Optional.cs index a9e1d078e..6ea046c87 100644 --- a/DisCatSharp/Entities/Optional.cs +++ b/DisCatSharp/Entities/Optional.cs @@ -100,6 +100,16 @@ public interface IOptional private readonly T _val; + /// + /// Creates a new with specified value. + /// + /// Value of this option. + public Optional(T value) + { + this._val = value; + this.HasValue = true; + } + /// /// Performs a mapping operation on the current , turning it into an Optional holding a /// instance if the source optional contains a value; otherwise, returns an @@ -214,9 +224,7 @@ public override int GetHashCode() => this.Map(x => x.GetHashCode()).ValueOrDefault(); public static implicit operator Optional(T val) -#pragma warning disable 0618 - => Optional.Some(val); -#pragma warning restore 0618 + => new(val); public static explicit operator T(Optional opt) => opt.Value;