Skip to content

Commit

Permalink
exercises(rna-transcription): remove untested RnaError (#258)
Browse files Browse the repository at this point in the history
Clarify that the exercise does not currently require validating the
input.

Closes: #214
  • Loading branch information
ee7 authored Mar 16, 2023
1 parent 477e659 commit 794420a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Instructions append

## Input validation

This exercise does not require you to validate the input DNA strand.
Each tested input contains only the characters `A`, `C`, `G`, or `T`.
11 changes: 2 additions & 9 deletions exercises/practice/rna-transcription/.meta/example.zig
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
const std = @import("std");
const mem = std.mem;

pub const RnaError = error{
IllegalDnaNucleotide,
};

pub fn toRna(allocator: mem.Allocator, dna: []const u8) ![]const u8 {
pub fn toRna(allocator: mem.Allocator, dna: []const u8) mem.Allocator.Error![]const u8 {
var rna_slice = try allocator.alloc(u8, dna.len);
for (dna) |dna_nucleotide, i| {
switch (dna_nucleotide) {
'A' => rna_slice[i] = 'U',
'C' => rna_slice[i] = 'G',
'G' => rna_slice[i] = 'C',
'T' => rna_slice[i] = 'A',
else => {
allocator.free(rna_slice);
return RnaError.IllegalDnaNucleotide;
},
else => unreachable,
}
}
return rna_slice;
Expand Down
2 changes: 1 addition & 1 deletion exercises/practice/rna-transcription/rna_transcription.zig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Import the appropriate standard library and modules

pub fn toRna(allocator: mem.Allocator, dna: []const u8) (RnaError || mem.Allocator.Error)![]const u8 {
pub fn toRna(allocator: mem.Allocator, dna: []const u8) mem.Allocator.Error![]const u8 {
_ = allocator;
_ = dna;
@compileError("please implement the toRna function");
Expand Down

0 comments on commit 794420a

Please sign in to comment.