mirror of
https://github.com/starship/starship.git
synced 2024-11-27 02:35:25 +01:00
refactor(singularity): use ?
operator (#2518)
This commit is contained in:
parent
cf68f54611
commit
1336944ab7
@ -7,8 +7,7 @@ use crate::formatter::StringFormatter;
|
||||
///
|
||||
/// Will display the Singularity image if `$SINGULARITY_NAME` is set.
|
||||
pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
||||
let singularity_env = context.get_env("SINGULARITY_NAME");
|
||||
singularity_env.as_ref()?;
|
||||
let singularity_env = context.get_env("SINGULARITY_NAME")?;
|
||||
|
||||
let mut module = context.new_module("singularity");
|
||||
let config: SingularityConfig = SingularityConfig::try_load(module.config);
|
||||
@ -24,7 +23,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
||||
_ => None,
|
||||
})
|
||||
.map(|variable| match variable {
|
||||
"env" => singularity_env.as_ref().map(Ok),
|
||||
"env" => Some(Ok(&singularity_env)),
|
||||
_ => None,
|
||||
})
|
||||
.parse(None)
|
||||
|
Loading…
Reference in New Issue
Block a user