forked from extern/nushell
removed unwraps (#430)
This commit is contained in:
@ -38,7 +38,7 @@ impl Command for Format {
|
||||
match specified_pattern {
|
||||
Err(e) => Err(e),
|
||||
Ok(pattern) => {
|
||||
let string_pattern = pattern.as_string().unwrap();
|
||||
let string_pattern = pattern.as_string()?;
|
||||
let ops = extract_formatting_operations(string_pattern);
|
||||
format(input, &ops, call.head)
|
||||
}
|
||||
@ -184,9 +184,7 @@ fn format_record(
|
||||
val: col_name.clone(),
|
||||
span: Span::unknown(),
|
||||
}]) {
|
||||
Ok(value_at_column) => {
|
||||
output.push_str(value_at_column.as_string().unwrap().as_str())
|
||||
}
|
||||
Ok(value_at_column) => output.push_str(value_at_column.as_string()?.as_str()),
|
||||
Err(se) => return Err(se),
|
||||
}
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ fn action(
|
||||
span: head,
|
||||
}
|
||||
} else {
|
||||
let c = character.as_ref().unwrap(); // we already know this flag needs to exist because the command is type checked before we call the action function
|
||||
let c = character.as_ref().expect("we already know this flag needs to exist because the command is type checked before we call the action function");
|
||||
let mut res = c.repeat(s - val.chars().count());
|
||||
res += val;
|
||||
Value::String {
|
||||
|
@ -143,7 +143,7 @@ fn action(
|
||||
}
|
||||
} else {
|
||||
let mut res = val.to_string();
|
||||
res += &character.as_ref().unwrap().repeat(s - val.chars().count());
|
||||
res += &character.as_ref().expect("we already know this flag needs to exist because the command is type checked before we call the action function").repeat(s - val.chars().count());
|
||||
Value::String {
|
||||
val: res,
|
||||
span: head,
|
||||
|
@ -143,7 +143,7 @@ where
|
||||
input,
|
||||
);
|
||||
let to_trim = match options.character.as_ref() {
|
||||
Some(v) => v.as_string().unwrap().chars().next(),
|
||||
Some(v) => v.as_string()?.chars().next(),
|
||||
None => None,
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user