Skip to content

Commit c516c5e

Browse files
committed
Update ConstraintStore.cs
1 parent b616220 commit c516c5e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/Draco.Compiler/Internal/Solver/ConstraintStore.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections;
23
using System.Collections.Generic;
34
using System.Diagnostics.CodeAnalysis;
45
using System.Linq;
@@ -9,7 +10,7 @@ namespace Draco.Compiler.Internal.Solver;
910
/// <summary>
1011
/// A data-type to efficiently store and query constraints.
1112
/// </summary>
12-
internal sealed class ConstraintStore
13+
internal sealed class ConstraintStore : IEnumerable<Constraint>
1314
{
1415
/// <summary>
1516
/// The number of constraints in the store.
@@ -18,6 +19,9 @@ internal sealed class ConstraintStore
1819

1920
private readonly Dictionary<Type, List<Constraint>> constraints = [];
2021

22+
public IEnumerator<Constraint> GetEnumerator() => this.constraints.Values.SelectMany(x => x).GetEnumerator();
23+
IEnumerator IEnumerable.GetEnumerator() => this.GetEnumerator();
24+
2125
/// <summary>
2226
/// Adds a constraint to the store.
2327
/// </summary>
@@ -141,5 +145,5 @@ private List<Constraint> GetConstraintList(Type type)
141145

142146
[DoesNotReturn]
143147
private static void ThrowConstraintNotFound(Constraint constraint) =>
144-
throw new InvalidOperationException($"Constraint {constraint} not found in the store.");
148+
throw new InvalidOperationException($"constraint {constraint} not found in the store");
145149
}

0 commit comments

Comments
 (0)