-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathParseResult.cs
More file actions
49 lines (42 loc) · 1.14 KB
/
Copy pathParseResult.cs
File metadata and controls
49 lines (42 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System.Collections;
namespace TedToolkit.InterpolatedParser;
/// <summary>
/// The parse result
/// </summary>
public readonly struct ParseResult(params IEnumerable<bool> results) : IEnumerable<bool>
{
/// <summary>
/// All results
/// </summary>
public bool[] Results { get; init; } = results.ToArray();
/// <summary>
/// The result.
/// </summary>
public bool Result => Results.Length > 0 && Results.All(b => b);
/// <summary>
/// Conversion
/// </summary>
/// <param name="result"></param>
/// <returns></returns>
public static implicit operator bool(ParseResult result)
{
return result.Result;
}
/// <summary>
/// Convert from a bool
/// </summary>
/// <param name="result"></param>
/// <returns></returns>
public static implicit operator ParseResult(bool result)
{
return new ParseResult(result);
}
public IEnumerator<bool> GetEnumerator()
{
return ((IEnumerable<bool>)Results).GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return Results.GetEnumerator();
}
}