fn compress_cigar(cigar: &[u8]) -> Option<Vec<u8>> {
    let mut result = Vec::new();

    let mut iter = cigar.iter();
    let mut last_op = iter.next().copied()?;
    let mut last_count = 1;
    for &op in iter {
        if op == last_op {
            last_count += 1;
        } else {
            let op_char = char::from(last_op);
            let string = format!("{}{}", last_count, op_char);
            result.extend(string.as_bytes());
            last_op = op;
            last_count = 1;
        }
    }

    let op_char = char::from(last_op);
    let string = format!("{}{}", last_count, op_char);
    result.extend(string.as_bytes());

    Some(result)
}
/// "Compresses" a cigar string produced by WFA (like "MMMXXII") into
/// a regular cigar string with operation counts (e.g. "3M2X2I")
"Compresses" a cigar string produced by WFA (like "MMMXXII") into
a regular cigar string with operation counts
" Compresses " a cigar string produced by WFA ( like " MMMXXII " ) into a regular cigar string with operation counts
fn compress_cigar(cigar: &[u8]) -> Option<Vec<u8>> {
    let mut result = Vec::new();
    let mut iter = cigar.iter();
    let mut last_op = iter.next().copied()?;
    let mut last_count = 1;
    for &op in iter {
        if op == last_op {
            last_count += 1;
        } else {
            let op_char = char::from(last_op);
            let string = format!("{}{}", last_count, op_char);
            result.extend(string.as_bytes());
            last_op = op;
            last_count = 1;
        }
    }
    let op_char = char::from(last_op);
    let string = format!("{}{}", last_count, op_char);
    result.extend(string.as_bytes());
    Some(result)
}
fn compress_cigar ( cigar : & [ u8 ] ) -> Option < Vec < u8 > > { let mut result = Vec :: new ( ) ; let mut iter = cigar . iter ( ) ; let mut last_op = iter . next ( ) . copied ( ) ? ; let mut last_count = 1 ; for & op in iter { if op == last_op { last_count += 1 ; } else { let op_char = char :: from ( last_op ) ; let string = format ! ( " " last_count op_char ) ; result . extend ( string . as_bytes ( ) ) ; last_op = op ; last_count = 1 ; } } let op_char = char :: from ( last_op ) ; let string = format ! ( " " last_count op_char ) ; result . extend ( string . as_bytes ( ) ) ; Some ( result ) }
"Compresses" a cigar string produced by WFA (like "MMMXXII") into
a regular cigar string with operation counts (e.g.
" Compresses " a cigar string produced by WFA ( like " MMMXXII " ) into a regular cigar string with operation counts ( e . g .
cigar
&[u8]