@@ -262,14 +262,14 @@ where
262
262
}
263
263
264
264
/// Schedule a state change that replaces the active state with the given state.
265
- /// This will fail if there is a scheduled operation, or if the given `state` matches the
266
- /// current state
265
+ /// This will fail if there is a scheduled operation, pending transition, or if the given
266
+ /// `state` matches the current state
267
267
pub fn set ( & mut self , state : T ) -> Result < ( ) , StateError > {
268
268
if self . stack . last ( ) . unwrap ( ) == & state {
269
269
return Err ( StateError :: AlreadyInState ) ;
270
270
}
271
271
272
- if self . scheduled . is_some ( ) {
272
+ if self . scheduled . is_some ( ) || self . transition . is_some ( ) {
273
273
return Err ( StateError :: StateAlreadyQueued ) ;
274
274
}
275
275
@@ -289,14 +289,14 @@ where
289
289
}
290
290
291
291
/// Schedule a state change that replaces the full stack with the given state.
292
- /// This will fail if there is a scheduled operation, or if the given `state` matches the
293
- /// current state
292
+ /// This will fail if there is a scheduled operation, pending transition, or if the given
293
+ /// `state` matches the current state
294
294
pub fn replace ( & mut self , state : T ) -> Result < ( ) , StateError > {
295
295
if self . stack . last ( ) . unwrap ( ) == & state {
296
296
return Err ( StateError :: AlreadyInState ) ;
297
297
}
298
298
299
- if self . scheduled . is_some ( ) {
299
+ if self . scheduled . is_some ( ) || self . transition . is_some ( ) {
300
300
return Err ( StateError :: StateAlreadyQueued ) ;
301
301
}
302
302
@@ -321,7 +321,7 @@ where
321
321
return Err ( StateError :: AlreadyInState ) ;
322
322
}
323
323
324
- if self . scheduled . is_some ( ) {
324
+ if self . scheduled . is_some ( ) || self . transition . is_some ( ) {
325
325
return Err ( StateError :: StateAlreadyQueued ) ;
326
326
}
327
327
@@ -342,7 +342,7 @@ where
342
342
343
343
/// Same as [`Self::set`], but does a pop operation instead of a set operation
344
344
pub fn pop ( & mut self ) -> Result < ( ) , StateError > {
345
- if self . scheduled . is_some ( ) {
345
+ if self . scheduled . is_some ( ) || self . transition . is_some ( ) {
346
346
return Err ( StateError :: StateAlreadyQueued ) ;
347
347
}
348
348
@@ -365,9 +365,9 @@ where
365
365
}
366
366
367
367
/// Schedule a state change that restarts the active state.
368
- /// This will fail if there is a scheduled operation
368
+ /// This will fail if there is a scheduled operation or a pending transition
369
369
pub fn restart ( & mut self ) -> Result < ( ) , StateError > {
370
- if self . scheduled . is_some ( ) {
370
+ if self . scheduled . is_some ( ) || self . transition . is_some ( ) {
371
371
return Err ( StateError :: StateAlreadyQueued ) ;
372
372
}
373
373
0 commit comments