Skip to content

Commit 70ecf1c

Browse files
shingtaklam1324petertseng
authored andcommitted
rna-transcription: abbreviate to 'RNA' and 'DNA' (#410)
Closes #407
1 parent 46f73fd commit 70ecf1c

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

exercises/rna-transcription/example.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
#[derive(PartialEq, Eq, Debug)]
2-
pub struct RibonucleicAcid {
2+
pub struct RNA {
33
nucleotides: String
44
}
55

6-
impl RibonucleicAcid {
7-
pub fn new(nucleotides: &str) -> RibonucleicAcid {
8-
RibonucleicAcid { nucleotides: nucleotides.to_string() }
6+
impl RNA {
7+
pub fn new(nucleotides: &str) -> RNA {
8+
RNA { nucleotides: nucleotides.to_string() }
99
}
1010
}
1111

1212
#[derive(PartialEq, Eq, Debug)]
13-
pub struct DeoxyribonucleicAcid {
13+
pub struct DNA {
1414
nucleotides: String
1515
}
1616

@@ -24,15 +24,15 @@ fn transcribe_dna_rna(c: char) -> Option<char> {
2424
}
2525
}
2626

27-
impl DeoxyribonucleicAcid {
28-
pub fn new(nucleotides: &str) -> DeoxyribonucleicAcid {
29-
DeoxyribonucleicAcid { nucleotides: nucleotides.to_string() }
27+
impl DNA {
28+
pub fn new(nucleotides: &str) -> DNA {
29+
DNA { nucleotides: nucleotides.to_string() }
3030
}
3131

32-
pub fn to_rna(&self) -> Result<RibonucleicAcid, ()> {
32+
pub fn to_rna(&self) -> Result<RNA, ()> {
3333
let rna_nucleotides: String = self.nucleotides.chars().filter_map(transcribe_dna_rna).collect();
3434
if rna_nucleotides.len() == self.nucleotides.len() {
35-
Ok(RibonucleicAcid { nucleotides: rna_nucleotides })
35+
Ok(RNA { nucleotides: rna_nucleotides })
3636
} else {
3737
Err(())
3838
}

exercises/rna-transcription/tests/rna-transcription.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,54 +2,54 @@ extern crate rna_transcription as dna;
22

33
#[test]
44
fn test_acid_equals_acid() {
5-
assert_eq!(dna::RibonucleicAcid::new("CGA"), dna::RibonucleicAcid::new("CGA"));
6-
assert_ne!(dna::RibonucleicAcid::new("CGA"), dna::RibonucleicAcid::new("AGC"));
5+
assert_eq!(dna::RNA::new("CGA"), dna::RNA::new("CGA"));
6+
assert_ne!(dna::RNA::new("CGA"), dna::RNA::new("AGC"));
77
}
88

99
#[test]
1010
#[ignore]
1111
fn test_transcribes_cytosine_guanine() {
12-
assert_eq!(Ok(dna::RibonucleicAcid::new("G")), dna::DeoxyribonucleicAcid::new("C").to_rna());
12+
assert_eq!(Ok(dna::RNA::new("G")), dna::DNA::new("C").to_rna());
1313
}
1414

1515
#[test]
1616
#[ignore]
1717
fn test_transcribes_guanine_cytosine() {
18-
assert_eq!(Ok(dna::RibonucleicAcid::new("C")), dna::DeoxyribonucleicAcid::new("G").to_rna());
18+
assert_eq!(Ok(dna::RNA::new("C")), dna::DNA::new("G").to_rna());
1919
}
2020

2121
#[test]
2222
#[ignore]
2323
fn test_transcribes_adenine_uracil() {
24-
assert_eq!(Ok(dna::RibonucleicAcid::new("U")), dna::DeoxyribonucleicAcid::new("A").to_rna());
24+
assert_eq!(Ok(dna::RNA::new("U")), dna::DNA::new("A").to_rna());
2525
}
2626

2727
#[test]
2828
#[ignore]
2929
fn test_transcribes_thymine_to_adenine() {
30-
assert_eq!(Ok(dna::RibonucleicAcid::new("A")), dna::DeoxyribonucleicAcid::new("T").to_rna());
30+
assert_eq!(Ok(dna::RNA::new("A")), dna::DNA::new("T").to_rna());
3131
}
3232

3333
#[test]
3434
#[ignore]
3535
fn test_transcribes_all_dna_to_rna() {
36-
assert_eq!(Ok(dna::RibonucleicAcid::new("UGCACCAGAAUU")), dna::DeoxyribonucleicAcid::new("ACGTGGTCTTAA").to_rna())
36+
assert_eq!(Ok(dna::RNA::new("UGCACCAGAAUU")), dna::DNA::new("ACGTGGTCTTAA").to_rna())
3737
}
3838

3939
#[test]
4040
#[ignore]
4141
fn handles_invalid_input() {
42-
assert!(dna::DeoxyribonucleicAcid::new("U").to_rna().is_err());
42+
assert!(dna::DNA::new("U").to_rna().is_err());
4343
}
4444

4545
#[test]
4646
#[ignore]
4747
fn handles_completely_invalid_input() {
48-
assert!(dna::DeoxyribonucleicAcid::new("XXX").to_rna().is_err());
48+
assert!(dna::DNA::new("XXX").to_rna().is_err());
4949
}
5050

5151
#[test]
5252
#[ignore]
5353
fn handles_partially_invalid_input() {
54-
assert!(dna::DeoxyribonucleicAcid::new("ACGTXXXCTTAA").to_rna().is_err());
54+
assert!(dna::DNA::new("ACGTXXXCTTAA").to_rna().is_err());
5555
}

0 commit comments

Comments
 (0)