Skip to content

Commit

Permalink
Merge pull request #54 from Byron/master
Browse files Browse the repository at this point in the history
Improve README and fix compile warnings
  • Loading branch information
tailhook committed Aug 10, 2020
2 parents aad5701 + 26b7cbb commit a236246
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
4 changes: 2 additions & 2 deletions README.rst
Expand Up @@ -25,13 +25,13 @@ Here is the comprehensive example:
Io(err: io::Error) {
from()
display("I/O error: {}", err)
cause(err)
source(err)
}
Other(descr: &'static str) {
display("Error {}", descr)
}
IoAt { place: &'static str, err: io::Error } {
cause(err)
source(err)
display(me) -> ("io error at {}: {}", place, err)
from(s: String) -> {
place: "some string",
Expand Down
14 changes: 6 additions & 8 deletions src/lib.rs
Expand Up @@ -997,7 +997,7 @@ mod test {

#[test]
fn bare_item_trait() {
let err: &Error = &Bare::Two;
let err: &dyn Error = &Bare::Two;
assert_eq!(format!("{}", err), "Two".to_string());
assert_eq!(format!("{:?}", err), "Two".to_string());
assert!(err.source().is_none());
Expand Down Expand Up @@ -1075,7 +1075,7 @@ mod test {
#[test]
fn tuple_wrapper_trait_str() {
let desc = "hello";
let err: &Error = &TupleWrapper::Other(desc);
let err: &dyn Error = &TupleWrapper::Other(desc);
assert_eq!(format!("{}", err), format!("Error: {}", desc));
assert_eq!(format!("{:?}", err), format!("Other({:?})", desc));
assert!(err.source().is_none());
Expand All @@ -1087,7 +1087,7 @@ mod test {
let source = String::from_utf8(invalid_utf8.clone())
.unwrap_err()
.utf8_error();
let err: &Error = &TupleWrapper::FromUtf8Error(source.clone(), invalid_utf8.clone());
let err: &dyn Error = &TupleWrapper::FromUtf8Error(source.clone(), invalid_utf8.clone());
assert_eq!(
format!("{}", err),
format!(
Expand Down Expand Up @@ -1162,7 +1162,7 @@ mod test {
let source = String::from_utf8(invalid_utf8.clone())
.unwrap_err()
.utf8_error();
let err: &Error = &StructWrapper::Utf8Error {
let err: &dyn Error = &StructWrapper::Utf8Error {
err: source.clone(),
hint: Some("nonsense"),
};
Expand Down Expand Up @@ -1276,9 +1276,7 @@ mod test {

#[test]
fn path_context() {
fn parse_utf<P: AsRef<Path>>(s: &[u8], p: P)
-> Result<(), ContextErr>
{
fn parse_utf<P: AsRef<Path>>(s: &[u8], p: P) -> Result<(), ContextErr> {
::std::str::from_utf8(s).context(p)?;
Ok(())
}
Expand Down Expand Up @@ -1309,7 +1307,7 @@ mod test {
let cause = String::from_utf8(invalid_utf8.clone())
.unwrap_err()
.utf8_error();
let err: &Error = &StructWrapper::Utf8Error {
let err: &dyn Error = &StructWrapper::Utf8Error {
err: cause.clone(),
hint: Some("nonsense"),
};
Expand Down

0 comments on commit a236246

Please sign in to comment.