mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 22:07:57 +02:00
removed unwraps (#430)
This commit is contained in:
@ -114,11 +114,13 @@ fn into_int(
|
||||
None => 10,
|
||||
};
|
||||
|
||||
if !(2..=36).contains(&radix) {
|
||||
return Err(ShellError::UnsupportedInput(
|
||||
"Radix must lie in the range [2, 36]".to_string(),
|
||||
options.radix.unwrap().span().unwrap(),
|
||||
));
|
||||
if let Some(val) = &options.radix {
|
||||
if !(2..=36).contains(&radix) {
|
||||
return Err(ShellError::UnsupportedInput(
|
||||
"Radix must lie in the range [2, 36]".to_string(),
|
||||
val.span()?,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
input.map(
|
||||
|
@ -139,11 +139,13 @@ fn string_helper(
|
||||
let column_paths: Vec<CellPath> = call.rest(engine_state, stack, 0)?;
|
||||
let config = stack.get_config()?;
|
||||
|
||||
if decimals && decimals_value.is_some() && decimals_value.unwrap().is_negative() {
|
||||
return Err(ShellError::UnsupportedInput(
|
||||
"Cannot accept negative integers for decimals arguments".to_string(),
|
||||
head,
|
||||
));
|
||||
if let Some(decimal_val) = decimals_value {
|
||||
if decimals && decimal_val.is_negative() {
|
||||
return Err(ShellError::UnsupportedInput(
|
||||
"Cannot accept negative integers for decimals arguments".to_string(),
|
||||
head,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
input.map(
|
||||
@ -192,7 +194,7 @@ pub fn action(
|
||||
}
|
||||
Value::Float { val, .. } => {
|
||||
if decimals {
|
||||
let decimal_value = digits.unwrap() as usize;
|
||||
let decimal_value = digits.unwrap_or(2) as usize;
|
||||
Value::String {
|
||||
val: format!("{:.*}", decimal_value, val),
|
||||
span,
|
||||
|
Reference in New Issue
Block a user