Kixunil / genio

A type safe, low level replacement for `std::io`.
60 stars 11 forks source link

#[derive(Debug)] for Error types? #20

Closed Kevingislason closed 4 years ago

Kevingislason commented 4 years ago

Is there any reason genio error types shouldn't derive the Debug trait?

I'm trying to write my own implementation of Cursor for (eventually) an embedded project. I would like to be able to call cursor.read_exact(&mut buffer) and then unwrap the result to check for errors. But unwrap requires an implementation of Debug.

When I try to run this code:

  let mut buf = [0; 5];
  let mut cursor = Cursor::new(vec![1u8, 2u8, 3u8]);
  cursor.read_exact(&mut buf).unwrap();

I get this error:

no method named `unwrap` found for type `std::result::Result<(), genio::error::ReadExactError<void::Void>>` in the current scope

note: the method `unwrap` exists but the following trait bounds were not satisfied: genio::error::ReadExactError<void::Void> : std::fmt::Debug
Kixunil commented 4 years ago

Definitely an oversight! No good reason to not derive Debug. Thanks for heads up!