Sha256: d18f7b3760be74ba4df70e56d34f4829648d9df409009ba7950880bca27d0f7c

Contents?: true

Size: 860 Bytes

Versions: 180

Compression:

Stored size: 860 Bytes

Contents

#[derive(PartialEq, Eq, Debug)]
pub struct RibonucleicAcid {
    nucleotides: String
}

impl RibonucleicAcid {
    pub fn new(nucleotides: &str) -> RibonucleicAcid {
        RibonucleicAcid { nucleotides: nucleotides.to_string() }
    }
}

#[derive(PartialEq, Eq, Debug)]
pub struct DeoxyribonucleicAcid {
    nucleotides: String
}

fn transcribe_dna_rna(c: char) -> char {
    match c {
        'C' => 'G',
        'G' => 'C',
        'A' => 'U',
        'T' => 'A',
        _   => c
    }
}

impl DeoxyribonucleicAcid {
    pub fn new(nucleotides: &str) -> DeoxyribonucleicAcid {
        DeoxyribonucleicAcid { nucleotides: nucleotides.to_string() }
    }

    pub fn to_rna(&self) -> RibonucleicAcid {
        let rna_nucleotides = self.nucleotides.chars().map(transcribe_dna_rna).collect();
        RibonucleicAcid { nucleotides: rna_nucleotides }
    }
}

Version data entries

180 entries across 180 versions & 1 rubygems

Version Path
trackler-2.1.0.24 tracks/rust/exercises/rna-transcription/example.rs
trackler-2.1.0.23 tracks/rust/exercises/rna-transcription/example.rs
trackler-2.1.0.22 tracks/rust/exercises/rna-transcription/example.rs
trackler-2.1.0.21 tracks/rust/exercises/rna-transcription/example.rs
trackler-2.1.0.20 tracks/rust/exercises/rna-transcription/example.rs
trackler-2.1.0.19 tracks/rust/exercises/rna-transcription/example.rs
trackler-2.1.0.18 tracks/rust/exercises/rna-transcription/example.rs
trackler-2.1.0.17 tracks/rust/exercises/rna-transcription/example.rs
trackler-2.1.0.16 tracks/rust/exercises/rna-transcription/example.rs
trackler-2.1.0.15 tracks/rust/exercises/rna-transcription/example.rs
trackler-2.1.0.14 tracks/rust/exercises/rna-transcription/example.rs
trackler-2.1.0.13 tracks/rust/exercises/rna-transcription/example.rs
trackler-2.1.0.12 tracks/rust/exercises/rna-transcription/example.rs
trackler-2.1.0.11 tracks/rust/exercises/rna-transcription/example.rs
trackler-2.1.0.10 tracks/rust/exercises/rna-transcription/example.rs
trackler-2.1.0.9 tracks/rust/exercises/rna-transcription/example.rs
trackler-2.1.0.8 tracks/rust/exercises/rna-transcription/example.rs
trackler-2.1.0.7 tracks/rust/exercises/rna-transcription/example.rs
trackler-2.1.0.6 tracks/rust/exercises/rna-transcription/example.rs
trackler-2.1.0.5 tracks/rust/exercises/rna-transcription/example.rs