namespace Ellie.Marmalade; public readonly struct ParseResult { /// /// Whether the parsing was successful /// public bool IsSuccess { get; private init; } /// /// Parsed value. It should only have value if is set to true /// public T? Data { get; private init; } /// /// Instantiate a **successful** parse result /// /// Parsed value public ParseResult(T data) { Data = data; IsSuccess = true; } /// /// Create a new with IsSuccess = false /// /// A new public static ParseResult Fail() => new ParseResult { IsSuccess = false, Data = default, }; /// /// Create a new with IsSuccess = true /// /// Value of the parsed object /// A new public static ParseResult Success(T obj) => new ParseResult { IsSuccess = true, Data = obj, }; }