tracks/rust/exercises/rna-transcription/example.rs in trackler-2.2.1.72 vs tracks/rust/exercises/rna-transcription/example.rs in trackler-2.2.1.73

- old
+ new

@@ -1,18 +1,18 @@ #[derive(PartialEq, Eq, Debug)] -pub struct RibonucleicAcid { +pub struct RNA { nucleotides: String } -impl RibonucleicAcid { - pub fn new(nucleotides: &str) -> RibonucleicAcid { - RibonucleicAcid { nucleotides: nucleotides.to_string() } +impl RNA { + pub fn new(nucleotides: &str) -> RNA { + RNA { nucleotides: nucleotides.to_string() } } } #[derive(PartialEq, Eq, Debug)] -pub struct DeoxyribonucleicAcid { +pub struct DNA { nucleotides: String } fn transcribe_dna_rna(c: char) -> Option<char> { match c { @@ -22,18 +22,18 @@ 'T' => Some('A'), _ => None } } -impl DeoxyribonucleicAcid { - pub fn new(nucleotides: &str) -> DeoxyribonucleicAcid { - DeoxyribonucleicAcid { nucleotides: nucleotides.to_string() } +impl DNA { + pub fn new(nucleotides: &str) -> DNA { + DNA { nucleotides: nucleotides.to_string() } } - pub fn to_rna(&self) -> Result<RibonucleicAcid, ()> { + pub fn to_rna(&self) -> Result<RNA, ()> { let rna_nucleotides: String = self.nucleotides.chars().filter_map(transcribe_dna_rna).collect(); if rna_nucleotides.len() == self.nucleotides.len() { - Ok(RibonucleicAcid { nucleotides: rna_nucleotides }) + Ok(RNA { nucleotides: rna_nucleotides }) } else { Err(()) } } }