@@ -93,25 +93,18 @@ public bool Fold(MatchResult match)
9393 public MatchResult Result => _result ?? new MatchResult ( true , Left , Collected ) ;
9494 }
9595
96- partial struct EitherMatcher : IBranchPatternMatcher
96+ partial struct EitherMatcher ( int count , Leaves left , Leaves collected ) :
97+ IBranchPatternMatcher
9798 {
98- readonly int _count ;
9999 int _i ;
100- MatchResult _match ;
101-
102- public EitherMatcher ( int count , Leaves left , Leaves collected ) : this ( )
103- {
104- _count = count ;
105- ( Left , Collected ) = ( left , collected ) ;
106- _match = new MatchResult ( false , left , collected ) ;
107- }
100+ MatchResult _match = new ( false , left , collected ) ;
108101
109102 public int Index => _i - 1 ;
110103
111- public bool Next ( ) => BranchPatternMatcher . Next ( ref _i , _count ) ;
104+ public bool Next ( ) => BranchPatternMatcher . Next ( ref _i , count ) ;
112105
113- public Leaves Left { get ; }
114- public Leaves Collected { get ; }
106+ public Leaves Left { get ; } = left ;
107+ public Leaves Collected { get ; } = collected ;
115108
116109 public bool Match ( LeafPatternMatcher matcher , string name , ArgValueKind kind ) =>
117110 Fold ( matcher . Match ( Left , Collected , name , kind ) ) ;
@@ -131,20 +124,17 @@ public bool Fold(MatchResult match)
131124 public MatchResult Result => _match ;
132125 }
133126
134- partial struct OptionalMatcher : IBranchPatternMatcher
127+ partial struct OptionalMatcher ( int count , Leaves left , Leaves collected ) :
128+ IBranchPatternMatcher
135129 {
136- readonly int _count ;
137130 int _i ;
138131
139- public OptionalMatcher ( int count , Leaves left , Leaves collected ) : this ( ) =>
140- ( _count , Left , Collected ) = ( count , left , collected ) ;
141-
142132 public int Index => _i - 1 ;
143133
144- public bool Next ( ) => BranchPatternMatcher . Next ( ref _i , _count ) ;
134+ public bool Next ( ) => BranchPatternMatcher . Next ( ref _i , count ) ;
145135
146- public Leaves Left { get ; private set ; }
147- public Leaves Collected { get ; private set ; }
136+ public Leaves Left { get ; private set ; } = left ;
137+ public Leaves Collected { get ; private set ; } = collected ;
148138
149139 public bool Match ( LeafPatternMatcher matcher , string name , ArgValueKind kind ) =>
150140 Fold ( matcher . Match ( Left , Collected , name , kind ) ) ;
@@ -163,23 +153,23 @@ public bool Fold(MatchResult match)
163153 public MatchResult Result => new ( true , Left , Collected ) ;
164154 }
165155
166- partial struct OneOrMoreMatcher : IBranchPatternMatcher
156+ partial struct OneOrMoreMatcher (
157+ #pragma warning disable CS9113 // Parameter is unread.
158+ int count ,
159+ #pragma warning restore CS9113 // Parameter is unread.
160+ Leaves left ,
161+ Leaves collected ) :
162+ IBranchPatternMatcher
167163 {
168- readonly Leaves _initLeft , _initCollected ;
164+ readonly Leaves _initLeft = left , _initCollected = collected ;
169165 int _times ;
170166 Leaves ? _lastLeft ;
171167
172- public OneOrMoreMatcher ( int count , Leaves left , Leaves collected ) : this ( )
173- {
174- Left = _initLeft = left ;
175- Collected = _initCollected = collected ;
176- }
177-
178168 public int Index => 0 ;
179169 public bool Next ( ) => true ;
180170
181- public Leaves Left { get ; private set ; }
182- public Leaves Collected { get ; private set ; }
171+ public Leaves Left { get ; private set ; } = left ;
172+ public Leaves Collected { get ; private set ; } = collected ;
183173
184174 public bool Match ( LeafPatternMatcher matcher , string name , ArgValueKind kind ) =>
185175 Fold ( matcher . Match ( Left , Collected , name , kind ) ) ;
0 commit comments