mirror of
https://github.com/starship/starship.git
synced 2024-11-30 04:04:04 +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.
|
/// Will display the Singularity image if `$SINGULARITY_NAME` is set.
|
||||||
pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
||||||
let singularity_env = context.get_env("SINGULARITY_NAME");
|
let singularity_env = context.get_env("SINGULARITY_NAME")?;
|
||||||
singularity_env.as_ref()?;
|
|
||||||
|
|
||||||
let mut module = context.new_module("singularity");
|
let mut module = context.new_module("singularity");
|
||||||
let config: SingularityConfig = SingularityConfig::try_load(module.config);
|
let config: SingularityConfig = SingularityConfig::try_load(module.config);
|
||||||
@ -24,7 +23,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
|||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
.map(|variable| match variable {
|
.map(|variable| match variable {
|
||||||
"env" => singularity_env.as_ref().map(Ok),
|
"env" => Some(Ok(&singularity_env)),
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
.parse(None)
|
.parse(None)
|
||||||
|
Loading…
Reference in New Issue
Block a user