Because the match arms have to be exhaustive. That is, it has to cover every possible case.
So, gom68 included the s => s part, which pretty much says if the char (here called s, but can be called anything) isn't anything else listed above, just return that char. It's like the else after an if/else if.
If it encountered an 'O', which doesn't fit anything else (it's not an 'A', nor a 'T', ...), it won't replace that 'O'. It'll just keep that O as it is.
IMO, it should panic! instead, as any nucleotide not A, T, C or G is invalid.
Because the
match
arms have to be exhaustive. That is, it has to cover every possible case.So, gom68 included the
s => s
part, which pretty much says if the char (here calleds
, but can be called anything) isn't anything else listed above, just return that char. It's like theelse
after anif
/else if
.If it encountered an 'O', which doesn't fit anything else (it's not an 'A', nor a 'T', ...), it won't replace that 'O'. It'll just keep that O as it is.
IMO, it should
panic!
instead, as any nucleotide not A, T, C or G is invalid.This comment is hidden because it contains spoiler information about the solution
I thought I noticed the behavior of point 2. Nice to have it confirmed.