Merge branch 'depr' into 'master'
rust: Fix deprecation warnings See merge request Librem5/squeekboard!374
This commit is contained in:
@ -738,7 +738,6 @@ fn create_button<H: logging::Handler>(
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
use std::error::Error as ErrorTrait;
|
|
||||||
use ::logging::ProblemPanic;
|
use ::logging::ProblemPanic;
|
||||||
|
|
||||||
const THIS_FILE: &str = file!();
|
const THIS_FILE: &str = file!();
|
||||||
@ -786,7 +785,8 @@ mod tests {
|
|||||||
Err(e) => {
|
Err(e) => {
|
||||||
let mut handled = false;
|
let mut handled = false;
|
||||||
if let Error::Yaml(ye) = &e {
|
if let Error::Yaml(ye) = &e {
|
||||||
handled = ye.description() == "missing field `views`";
|
handled = ye.to_string()
|
||||||
|
.starts_with("missing field `views`");
|
||||||
};
|
};
|
||||||
if !handled {
|
if !handled {
|
||||||
println!("Unexpected error {:?}", e);
|
println!("Unexpected error {:?}", e);
|
||||||
@ -804,7 +804,7 @@ mod tests {
|
|||||||
Err(e) => {
|
Err(e) => {
|
||||||
let mut handled = false;
|
let mut handled = false;
|
||||||
if let Error::Yaml(ye) = &e {
|
if let Error::Yaml(ye) = &e {
|
||||||
handled = ye.description()
|
handled = ye.to_string()
|
||||||
.starts_with("unknown field `bad_field`");
|
.starts_with("unknown field `bad_field`");
|
||||||
};
|
};
|
||||||
if !handled {
|
if !handled {
|
||||||
|
|||||||
@ -31,22 +31,16 @@ pub enum Error {
|
|||||||
|
|
||||||
impl ::std::fmt::Display for Error {
|
impl ::std::fmt::Display for Error {
|
||||||
fn fmt(&self, out: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
|
fn fmt(&self, out: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
|
||||||
use ::std::error::Error;
|
out.write_str(match self {
|
||||||
out.write_str(self.description())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ::std::error::Error for Error {
|
|
||||||
fn description(&self) -> &str {
|
|
||||||
match self {
|
|
||||||
&Error::NotWellFormed => "Language tag is not well-formed.",
|
&Error::NotWellFormed => "Language tag is not well-formed.",
|
||||||
// this is exception: here we do want exhaustive match so we don't publish version with
|
// this is exception: here we do want exhaustive match so we don't publish version with
|
||||||
// missing descriptions by mistake.
|
// missing descriptions by mistake.
|
||||||
&Error::__NonExhaustive => panic!("Placeholder error must not be instantiated!"),
|
&Error::__NonExhaustive => panic!("Placeholder error must not be instantiated!"),
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Convenience Result alias.
|
/// Convenience Result alias.
|
||||||
type Result<T> = ::std::result::Result<T, Error>;
|
type Result<T> = ::std::result::Result<T, Error>;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user