79643957

Date: 2025-05-29 13:19:48
Score: 1.5
Natty:
Report link

As you already found out, you may reassign the if let ... else back to a let like:

let aws_credentials_provider_builder = aws_config::profile::ProfileFileCredentialsProvider::builder();
let aws_credentials_provider_builder = if let Some(aws_profile) = aws_profile_option {
    aws_credentials_provider_builder.profile_name(aws_profile)
} else {
    aws_credentials_provider_builder
};

however another approach would be to reassign the value via mut:

let mut aws_credentials_provider_builder = aws_config::profile::ProfileFileCredentialsProvider::builder();
if let Some(aws_profile) = aws_profile_option {
    aws_credentials_provider_builder = aws_credentials_provider_builder.profile_name(aws_profile)
};

Maybe we can find more approaches?

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Low reputation (0.5):
Posted by: Mindxxxd