mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 23:37:48 +02:00
Reduce again the number of match calls (#7815)
- Reduce the number of match calls (see commit messages) - A few miscellaneous improvements
This commit is contained in:
@ -98,32 +98,26 @@ fn parse_range(range: Value, head: Span) -> Result<(isize, isize, Span), ShellEr
|
||||
let start: isize = if start.is_empty() || start == "_" {
|
||||
0
|
||||
} else {
|
||||
match start.trim().parse() {
|
||||
Ok(s) => s,
|
||||
Err(_) => {
|
||||
return Err(ShellError::UnsupportedInput(
|
||||
"could not perform subbytes".to_string(),
|
||||
"with this range".to_string(),
|
||||
head,
|
||||
span,
|
||||
))
|
||||
}
|
||||
}
|
||||
start.trim().parse().map_err(|_| {
|
||||
ShellError::UnsupportedInput(
|
||||
"could not perform subbytes".to_string(),
|
||||
"with this range".to_string(),
|
||||
head,
|
||||
span,
|
||||
)
|
||||
})?
|
||||
};
|
||||
let end: isize = if end.is_empty() || end == "_" {
|
||||
isize::max_value()
|
||||
} else {
|
||||
match end.trim().parse() {
|
||||
Ok(s) => s,
|
||||
Err(_) => {
|
||||
return Err(ShellError::UnsupportedInput(
|
||||
"could not perform subbytes".to_string(),
|
||||
"with this range".to_string(),
|
||||
head,
|
||||
span,
|
||||
))
|
||||
}
|
||||
}
|
||||
end.trim().parse().map_err(|_| {
|
||||
ShellError::UnsupportedInput(
|
||||
"could not perform subbytes".to_string(),
|
||||
"with this range".to_string(),
|
||||
head,
|
||||
span,
|
||||
)
|
||||
})?
|
||||
};
|
||||
Ok((start, end, span))
|
||||
}
|
||||
|
Reference in New Issue
Block a user