build: Fix warnings on trait objects without dyn (#349)

* chore: Use dyn Trait

* build: Bump handlerbars

* build: Bump serde_cbor

* build: Bump compatible dependencies
This commit is contained in:
lzutao 2019-07-19 14:00:45 +07:00 committed by XAMPPRocky
parent 0a30359227
commit 5323ca8761
6 changed files with 237 additions and 256 deletions

475
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -21,7 +21,7 @@ repository = "XAMPPRocky/tokei"
repository = "XAMPPRocky/tokei"
[build-dependencies]
handlebars = "1.1.0"
handlebars = "2.0.1"
ignore = "0.4.7"
lazy_static = "1.3.0"
serde_json = "1.0.39"
@ -49,7 +49,7 @@ version = "0.3.2"
[dependencies.serde_cbor]
optional = true
version = "0.9.0"
version = "0.10.1"
[dependencies.serde_json]
optional = true

View file

@ -11,7 +11,7 @@ use handlebars::Handlebars;
use serde_json::Value;
use ignore::Walk;
fn main() -> Result<(), Box<error::Error>> {
fn main() -> Result<(), Box<dyn error::Error>> {
let out_dir = env::var_os("OUT_DIR").expect("No OUT_DIR variable.");
generate_languages(&out_dir)?;
generate_tests(&out_dir)?;
@ -19,7 +19,7 @@ fn main() -> Result<(), Box<error::Error>> {
Ok(())
}
fn generate_languages(out_dir: &OsStr) -> Result<(), Box<error::Error>> {
fn generate_languages(out_dir: &OsStr) -> Result<(), Box<dyn error::Error>> {
let handlebars = {
let mut h = Handlebars::new();
h.register_escape_fn(handlebars::no_escape);
@ -68,7 +68,7 @@ fn compare_json_str_len(a: &Value, b: &Value) -> cmp::Ordering {
max_b_size.cmp(&max_a_size)
}
fn generate_tests(out_dir: &OsStr) -> Result<(), Box<error::Error>> {
fn generate_tests(out_dir: &OsStr) -> Result<(), Box<dyn error::Error>> {
// Length of string literal below by number of languages
const INITIAL_BUFFER_SIZE: usize = 989 * 130;
let mut string = String::with_capacity(INITIAL_BUFFER_SIZE);

View file

@ -82,7 +82,7 @@ macro_rules! supported_formats {
None
}
pub fn print(&self, _languages: Languages) -> Result<String, Box<Error>> {
pub fn print(&self, _languages: Languages) -> Result<String, Box<dyn Error>> {
match *self {
$(
#[cfg(feature = $feature)] Format::$variant => {
@ -132,7 +132,7 @@ supported_formats!(
(cbor, "cbor", Cbor [serde_cbor, hex]) =>
|input| {
hex::FromHex::from_hex(input)
.map_err(|e: hex::FromHexError| <Box<Error>>::from(e))
.map_err(|e: hex::FromHexError| <Box<dyn Error>>::from(e))
.and_then(|hex: Vec<_>| Ok(serde_cbor::from_slice(&hex)?))
},
|languages| serde_cbor::to_vec(&languages).map(hex::encode),

View file

@ -18,7 +18,7 @@ use crate::{
input::*,
};
fn main() -> Result<(), Box<Error>> {
fn main() -> Result<(), Box<dyn Error>> {
let mut cli = Cli::from_args();
if cli.print_languages {

View file

@ -213,7 +213,7 @@ mod tests {
let mut config = Config::default();
let mut languages = Languages::new();
fs::create_dir_all(&child_dir).expect(&format!("Couldn't create {:?}", child_dir));
fs::create_dir_all(&child_dir).unwrap_or_else(|_| panic!("Couldn't create {:?}", child_dir));
fs::write(parent_dir.path().join(".ignore"), IGNORE_PATTERN)
.expect("Couldn't create .gitinore.");
fs::write(child_dir.join(FILE_NAME), FILE_CONTENTS)