aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--askama_shared/src/filters/mod.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/askama_shared/src/filters/mod.rs b/askama_shared/src/filters/mod.rs
index 8306ba3..64e1259 100644
--- a/askama_shared/src/filters/mod.rs
+++ b/askama_shared/src/filters/mod.rs
@@ -125,7 +125,7 @@ where
#[cfg(feature = "humansize")]
/// Returns adequate string representation (in KB, ..) of number of bytes
-pub fn filesizeformat(b: usize) -> Result<String> {
+pub fn filesizeformat<B: FileSize>(b: &B) -> Result<String> {
b.file_size(file_size_opts::DECIMAL)
.map_err(|_| Fmt(fmt::Error))
}
@@ -336,11 +336,11 @@ mod tests {
#[cfg(feature = "humansize")]
#[test]
fn test_filesizeformat() {
- assert_eq!(filesizeformat(0).unwrap(), "0 B");
- assert_eq!(filesizeformat(999).unwrap(), "999 B");
- assert_eq!(filesizeformat(1000).unwrap(), "1 KB");
- assert_eq!(filesizeformat(1023).unwrap(), "1.02 KB");
- assert_eq!(filesizeformat(1024).unwrap(), "1.02 KB");
+ 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");
}
#[cfg(feature = "percent-encoding")]