mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-26 21:03:12 +00:00
Refactor some more .unwrap/asserts
No use in asserting and then unwrapping, just .expect()
This commit is contained in:
parent
4859606e0c
commit
1cad9898d6
2 changed files with 8 additions and 10 deletions
12
src/env/environment_impl.rs
vendored
12
src/env/environment_impl.rs
vendored
|
@ -344,8 +344,8 @@ impl EnvScopedImpl {
|
|||
}
|
||||
|
||||
fn try_get_computed(&self, key: &wstr) -> Option<EnvVar> {
|
||||
let ev = ElectricVar::for_name(key);
|
||||
if ev.is_none() || !ev.unwrap().computed() {
|
||||
let ev = ElectricVar::for_name(key)?;
|
||||
if !ev.computed() {
|
||||
return None;
|
||||
}
|
||||
|
||||
|
@ -994,8 +994,8 @@ impl EnvStackImpl {
|
|||
let mut exports = false;
|
||||
if query.has_export_unexport {
|
||||
exports = query.exports;
|
||||
} else if oldvar.is_some() {
|
||||
exports = oldvar.unwrap().exports();
|
||||
} else if let Some(v) = oldvar {
|
||||
exports = v.exports();
|
||||
}
|
||||
|
||||
// Resolve whether to be a path variable.
|
||||
|
@ -1003,8 +1003,8 @@ impl EnvStackImpl {
|
|||
let pathvar;
|
||||
if query.has_pathvar_unpathvar {
|
||||
pathvar = query.pathvar;
|
||||
} else if oldvar.is_some() {
|
||||
pathvar = oldvar.unwrap().is_pathvar();
|
||||
} else if let Some(v) = oldvar {
|
||||
pathvar = v.is_pathvar();
|
||||
} else {
|
||||
pathvar = variable_should_auto_pathvar(key);
|
||||
}
|
||||
|
|
|
@ -760,8 +760,7 @@ impl<'c> Tokenizer<'c> {
|
|||
1,
|
||||
);
|
||||
} else if mode & TOK_MODE_SUBSHELL {
|
||||
assert!(!paran_offsets.is_empty());
|
||||
let offset_of_open_paran = *paran_offsets.last().unwrap();
|
||||
let offset_of_open_paran = *paran_offsets.last().expect("paran_offsets is empty");
|
||||
|
||||
return self.call_error(
|
||||
TokenizerError::unterminated_subshell,
|
||||
|
@ -771,8 +770,7 @@ impl<'c> Tokenizer<'c> {
|
|||
1,
|
||||
);
|
||||
} else if mode & TOK_MODE_CURLY_BRACES {
|
||||
assert!(!brace_offsets.is_empty());
|
||||
let offset_of_open_brace = *brace_offsets.last().unwrap();
|
||||
let offset_of_open_brace = *brace_offsets.last().expect("brace_offsets is empty");
|
||||
|
||||
return self.call_error(
|
||||
TokenizerError::unterminated_brace,
|
||||
|
|
Loading…
Reference in a new issue