fix(runtime): use unwrap not expect for unreachable code

cpli says to "make illegal states unrepresentable"

Acked-by: cpli
This commit is contained in:
buffet 2022-10-20 13:18:23 +00:00
parent 092360bce6
commit 2969d85f5e

View file

@ -48,7 +48,7 @@ impl<'a> PreparedCommand<'a> {
let mut words = command.0.iter().map(|word| { let mut words = command.0.iter().map(|word| {
let mut words = word.0.iter(); let mut words = word.0.iter();
let mut s = match words.next().expect("words need to have >1 parts") { let mut s = match words.next().unwrap() {
ast::WordPart::Text(text) => Cow::from(*text), ast::WordPart::Text(text) => Cow::from(*text),
}; };
@ -60,7 +60,7 @@ impl<'a> PreparedCommand<'a> {
s s
}); });
let cmd = words.next().expect("words need to have >1 parts"); let cmd = words.next().unwrap();
let args = words.collect(); let args = words.collect();
let redirect = command.1; let redirect = command.1;
@ -177,7 +177,7 @@ impl Shell {
let mut last_cmd = cmds let mut last_cmd = cmds
.next() .next()
.map(|cmd| PreparedCommand::new(cmd, self)) .map(|cmd| PreparedCommand::new(cmd, self))
.expect("pipelines need to have >1 commands"); .unwrap();
for cmd in cmds { for cmd in cmds {
let mut cmd = PreparedCommand::new(cmd, self); let mut cmd = PreparedCommand::new(cmd, self);
let (output, input) = create_pipe()?; let (output, input) = create_pipe()?;