-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add nostd tests #89
Add nostd tests #89
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,3 +56,4 @@ jobs: | |
cargo fmt -- --check | ||
- run: cargo build | ||
- run: cargo test | ||
- run: cargo test --no-default-features |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,11 +20,13 @@ pub enum Error { | |
size: usize, | ||
msg: &'static str, | ||
}, | ||
#[cfg(feature = "std")] | ||
/// A custom Scroll error for reporting messages to clients | ||
Custom(String), | ||
#[cfg(feature = "std")] | ||
Custom(String), | ||
/// A custom static Scroll error for reporting messages to clients | ||
CustomStatic(&'static str), | ||
/// Returned when IO based errors are encountered | ||
#[cfg(feature = "std")] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i just realized this got added; this is technically a breaking change, but nostd could never have worked with this, iiuc? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. correct, |
||
IO(io::Error), | ||
} | ||
|
||
|
@@ -36,6 +38,7 @@ impl error::Error for Error { | |
Error::BadOffset(_) => "BadOffset", | ||
Error::BadInput { .. } => "BadInput", | ||
Error::Custom(_) => "Custom", | ||
Error::CustomStatic(_) => "Custom", // Both Custom and CustomStatic are custom errors | ||
Error::IO(_) => "IO", | ||
} | ||
} | ||
|
@@ -45,6 +48,7 @@ impl error::Error for Error { | |
Error::BadOffset(_) => None, | ||
Error::BadInput { .. } => None, | ||
Error::Custom(_) => None, | ||
Error::CustomStatic(_) => None, | ||
Error::IO(ref io) => io.source(), | ||
} | ||
} | ||
|
@@ -73,6 +77,9 @@ impl Display for Error { | |
Error::Custom(ref msg) => { | ||
write!(fmt, "{}", msg) | ||
} | ||
Error::CustomStatic(msg) => { | ||
write!(fmt, "{msg}") | ||
} | ||
#[cfg(feature = "std")] | ||
Error::IO(ref err) => { | ||
write!(fmt, "{}", err) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok sorry to go back and forth, but can you remove these changes (adding CustomStatic); i thought it would be required to get the tests to pass, but a change like this (which is a breaking change) would require clients to update on the additional matches. Because this is just for fixing tests I don't think it should be included in this PR.
Additionally, it's unclear to me why we need this, since technically in a no-std environment the user of scroll could return BadInput which also has a static str (they could set size to 0 if they wanted).
Once the static str stuff is walked out we can merge this immediately, sorry for the busy work and appreciate you getting these changes in, but adding a new variant should be discussed separately I think (and isn't required for this, so let's remove it)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, np, removed