Skip to content

Commit

Permalink
feat: remove expect and return error
Browse files Browse the repository at this point in the history
  • Loading branch information
josecelano committed Oct 8, 2024
1 parent e08fe61 commit c235796
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 3 additions & 4 deletions src/rw/byte_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,9 @@ impl<W: Write> Writer for ByteWriter<W> {
}

fn get_captured_output(&mut self) -> Option<String> {
match &self.opt_captured_output {
Some(output) => Some(output.to_string()),
None => todo!(),
}
self.opt_captured_output
.as_ref()
.map(std::string::ToString::to_string)
}

fn print_captured_output(&self) {
Expand Down
4 changes: 2 additions & 2 deletions src/rw/string_writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl<W: Write> Writer for StringWriter<W> {
fn write_byte(&mut self, byte: u8) -> Result<(), Error> {
let c = byte as char;

self.writer.write_char(c).expect("error writing str");
self.writer.write_char(c)?;

self.output_string_length += 1;

Expand All @@ -42,7 +42,7 @@ impl<W: Write> Writer for StringWriter<W> {
}

fn write_str(&mut self, value: &str) -> Result<(), Error> {
self.writer.write_str(value).expect("error writing str");
self.writer.write_str(value)?;

self.output_string_length += value.len() as u64;

Expand Down

0 comments on commit c235796

Please sign in to comment.