mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-29 05:03:46 +08:00
Crash if invariant is broken
This commit is contained in:
parent
5407d0b785
commit
6ee81c0f15
|
@ -174,8 +174,10 @@ impl CompletionReceiver {
|
|||
/// \return a new, empty receiver whose limit is our remaining capacity.
|
||||
/// This is useful for e.g. recursive calls when you want to act on the result before adding it.
|
||||
pub fn subreceiver(&self) -> Self {
|
||||
// XXX: this should not need to be saturating, we have a faulty invariant
|
||||
let remaining_capacity = self.limit.saturating_sub(self.completions.len());
|
||||
let remaining_capacity = self
|
||||
.limit
|
||||
.checked_sub(self.completions.len())
|
||||
.expect("length should never be larger than limit");
|
||||
Self::new(remaining_capacity)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user