diff options
Diffstat (limited to '')
-rw-r--r-- | askama/Cargo.toml | 2 | ||||
-rw-r--r-- | askama/src/filters/mod.rs | 13 | ||||
-rw-r--r-- | askama/src/filters/yaml.rs | 10 | ||||
-rw-r--r-- | askama_actix/Cargo.toml | 2 |
4 files changed, 13 insertions, 14 deletions
diff --git a/askama/Cargo.toml b/askama/Cargo.toml index 7a4aef1..320d2a5 100644 --- a/askama/Cargo.toml +++ b/askama/Cargo.toml @@ -41,7 +41,7 @@ mime_guess = [] askama_derive = { version = "0.12.0", path = "../askama_derive" } askama_escape = { version = "0.10.3", path = "../askama_escape" } comrak = { version = "0.14", optional = true, default-features = false } -dep_humansize = { package = "humansize", version = "1.1.0", optional = true } +dep_humansize = { package = "humansize", version = "2", optional = true } dep_num_traits = { package = "num-traits", version = "0.2.6", optional = true } percent-encoding = { version = "2.1.0", optional = true } serde = { version = "1.0", optional = true, features = ["derive"] } diff --git a/askama/src/filters/mod.rs b/askama/src/filters/mod.rs index b9f1fc2..a4572e3 100644 --- a/askama/src/filters/mod.rs +++ b/askama/src/filters/mod.rs @@ -21,7 +21,7 @@ pub use self::yaml::yaml; use crate::error::Error::Fmt; use askama_escape::{Escaper, MarkupDisplay}; #[cfg(feature = "humansize")] -use dep_humansize::{file_size_opts, FileSize}; +use dep_humansize::{format_size_i, ToF64, DECIMAL}; #[cfg(feature = "num-traits")] use dep_num_traits::{cast::NumCast, Signed}; #[cfg(feature = "percent-encoding")] @@ -74,9 +74,8 @@ where #[cfg(feature = "humansize")] /// Returns adequate string representation (in KB, ..) of number of bytes -pub fn filesizeformat<B: FileSize>(b: &B) -> Result<String> { - b.file_size(file_size_opts::DECIMAL) - .map_err(|_| Fmt(fmt::Error)) +pub fn filesizeformat(b: &(impl ToF64 + Copy)) -> Result<String> { + Ok(format_size_i(*b, DECIMAL)) } #[cfg(feature = "percent-encoding")] @@ -399,9 +398,9 @@ mod tests { fn test_filesizeformat() { assert_eq!(filesizeformat(&0).unwrap(), "0 B"); assert_eq!(filesizeformat(&999u64).unwrap(), "999 B"); - assert_eq!(filesizeformat(&1000i32).unwrap(), "1 KB"); - assert_eq!(filesizeformat(&1023).unwrap(), "1.02 KB"); - assert_eq!(filesizeformat(&1024usize).unwrap(), "1.02 KB"); + assert_eq!(filesizeformat(&1000i32).unwrap(), "1 kB"); + assert_eq!(filesizeformat(&1023).unwrap(), "1.02 kB"); + assert_eq!(filesizeformat(&1024usize).unwrap(), "1.02 kB"); } #[cfg(feature = "percent-encoding")] diff --git a/askama/src/filters/yaml.rs b/askama/src/filters/yaml.rs index d71e630..ada0ca8 100644 --- a/askama/src/filters/yaml.rs +++ b/askama/src/filters/yaml.rs @@ -22,13 +22,13 @@ mod tests { #[test] fn test_yaml() { - assert_eq!(yaml(Html, true).unwrap().to_string(), "---\ntrue"); - assert_eq!(yaml(Html, "foo").unwrap().to_string(), "---\nfoo"); - assert_eq!(yaml(Html, &true).unwrap().to_string(), "---\ntrue"); - assert_eq!(yaml(Html, &"foo").unwrap().to_string(), "---\nfoo"); + assert_eq!(yaml(Html, true).unwrap().to_string(), "true\n"); + assert_eq!(yaml(Html, "foo").unwrap().to_string(), "foo\n"); + assert_eq!(yaml(Html, &true).unwrap().to_string(), "true\n"); + assert_eq!(yaml(Html, &"foo").unwrap().to_string(), "foo\n"); assert_eq!( yaml(Html, &vec!["foo", "bar"]).unwrap().to_string(), - "---\n- foo\n- bar" + "- foo\n- bar\n" ); } } diff --git a/askama_actix/Cargo.toml b/askama_actix/Cargo.toml index 075f78e..838ca6d 100644 --- a/askama_actix/Cargo.toml +++ b/askama_actix/Cargo.toml @@ -18,7 +18,7 @@ askama = { version = "0.11.2", path = "../askama", default-features = false, fea [dev-dependencies] actix-rt = { version = "2", default-features = false } -actix-test = "=0.1.0" +actix-test = "0.1" bytes = { version = "1" } [features] |