mirror of
https://github.com/nushell/nushell.git
synced 2025-07-01 07:00:37 +02:00
Remove usages of Call::positional_nth
(#12871)
# Description Following from #12867, this PR replaces usages of `Call::positional_nth` with existing spans. This removes several `expect`s from the code. Also remove unused `positional_nth_mut` and `positional_iter_mut`
This commit is contained in:
@ -154,30 +154,10 @@ impl Call {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn positional_iter_mut(&mut self) -> impl Iterator<Item = &mut Expression> {
|
||||
self.arguments
|
||||
.iter_mut()
|
||||
.take_while(|arg| match arg {
|
||||
Argument::Spread(_) => false, // Don't include positional arguments given to rest parameter
|
||||
_ => true,
|
||||
})
|
||||
.filter_map(|arg| match arg {
|
||||
Argument::Named(_) => None,
|
||||
Argument::Positional(positional) => Some(positional),
|
||||
Argument::Unknown(unknown) => Some(unknown),
|
||||
Argument::Spread(_) => None,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn positional_nth(&self, i: usize) -> Option<&Expression> {
|
||||
self.positional_iter().nth(i)
|
||||
}
|
||||
|
||||
// TODO this method is never used. Delete?
|
||||
pub fn positional_nth_mut(&mut self, i: usize) -> Option<&mut Expression> {
|
||||
self.positional_iter_mut().nth(i)
|
||||
}
|
||||
|
||||
pub fn positional_len(&self) -> usize {
|
||||
self.positional_iter().count()
|
||||
}
|
||||
|
Reference in New Issue
Block a user