package DX::Step::Backtrack;

use DX::Class;

with 'DX::Role::Step';

sub apply_to {
  my ($self, $ss) = @_;
  my ($first_alt, @rest_alt) = @{$ss->adjustments_made};
  return $ss->but(next_step => $ss->on_exhaustion_step) unless $first_alt;
  return $first_alt->[1]->but(next_step => $first_alt->[0]->alternative_step);
}

1;
