Repository: starship/starship
File: src/modules/aws.rs (Rust)

Code before:
    }

    // only display if credential_process is defined or has valid credentials
    if get_credential_process(context, aws_profile.as_ref()).is_none()
        && get_defined_credentials(context, aws_profile.as_ref()).is_none()
    {
        return None;
    }

    let duration = {
        get_credentials_duration(context, aws_profile.as_ref()).map(|duration| {
            if duration > 0 {
                render_time((duration * 1000) as u128, false)
            } else {
                config.expiration_symbol.to_string()
            }
        })
    };

    let mapped_region = if let Some(aws_region) = aws_region {
        Some(alias_name(aws_region, &config.region_aliases))
    } else {
        None
    };

    let mapped_profile = if let Some(aws_profile) = aws_profile {
        Some(alias_name(aws_profile, &config.profile_aliases))
    } else {
        None
    };

    let parsed = StringFormatter::new(config.format).and_then(|formatter| {
        formatter
            .map_meta(|variable, _| match variable {
                "symbol" => Some(config.symbol),
                _ => None,
            })
            .map_style(|variable| match variable {
                "style" => Some(Ok(config.style)),
                _ => None,
            })
            .map(|variable| match variable {
                "profile" => mapped_profile.as_ref().map(Ok),
                "region" => mapped_region.as_ref().map(Ok),
                "duration" => duration.as_ref().map(Ok),
                _ => None,
            })
            .parse(None, Some(context))
    });

    module.set_segments(match parsed {

Review comment (suggestion):
and this

```rust
let mapped_profile = alias_name(aws_profile, &config.profile_aliases);
```

Code after:
    }

    // only display if credential_process is defined or has valid credentials
    if get_credential_process(context, aws_profile.as_ref()).is_none()
        && get_defined_credentials(context, aws_profile.as_ref()).is_none()
    {
        return None;
    }

    let duration = {
        get_credentials_duration(context, aws_profile.as_ref()).map(|duration| {
            if duration > 0 {
                render_time((duration * 1000) as u128, false)
            } else {
                config.expiration_symbol.to_string()
            }
        })
    };

    let mapped_region = alias_name(aws_region, &config.region_aliases);

    let mapped_profile = alias_name(aws_profile, &config.profile_aliases);

    let parsed = StringFormatter::new(config.format).and_then(|formatter| {
        formatter
            .map_meta(|variable, _| match variable {
                "symbol" => Some(config.symbol),
                _ => None,
            })
            .map_style(|variable| match variable {
                "style" => Some(Ok(config.style)),
                _ => None,
            })
            .map(|variable| match variable {
                "profile" => mapped_profile.as_ref().map(Ok),
                "region" => mapped_region.as_ref().map(Ok),
                "duration" => duration.as_ref().map(Ok),
                _ => None,
            })
            .parse(None, Some(context))
    });

    module.set_segments(match parsed {
        Ok(segments) => segments,
        Err(error) => {
            log::warn!("Error in module `aws`: \n{}", error);
            return None;
        }
    });

    Some(module)