Skip to content

Commit

Permalink
use ok_or_else instead
Browse files Browse the repository at this point in the history
  • Loading branch information
tedil committed Jan 7, 2025
1 parent ca3c944 commit d700f68
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/sequences.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,9 @@ pub fn aa3_to_aa1(seq: &str) -> Result<String, Error> {
let mut result = String::with_capacity(seq.len() / 3);

for (i, aa3) in seq.as_bytes().chunks(3).enumerate() {
let aa1 = _aa3_to_aa1(aa3).ok_or(Error::InvalidThreeLetterAminoAcid(
format!("{:?}", aa3),
format!("{}", i + 1),
))? as char;
let aa1 = _aa3_to_aa1(aa3).ok_or_else(|| {
Error::InvalidThreeLetterAminoAcid(format!("{:?}", aa3), format!("{}", i + 1))
})? as char;
result.push(aa1);
}

Expand Down

0 comments on commit d700f68

Please sign in to comment.