diff options
-rw-r--r-- | askama_shared/src/filters/mod.rs | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/askama_shared/src/filters/mod.rs b/askama_shared/src/filters/mod.rs index f203348..9a5b160 100644 --- a/askama_shared/src/filters/mod.rs +++ b/askama_shared/src/filters/mod.rs @@ -249,7 +249,7 @@ pub fn indent(s: &dyn fmt::Display, width: &usize) -> Result<String> { #[cfg(feature = "num-traits")] /// Casts number to f64 -pub fn into_f64<T>(number: T) -> Result<f64> +pub fn into_f64<T>(number: &T) -> Result<f64> where T: NumCast, { @@ -258,7 +258,7 @@ where #[cfg(feature = "num-traits")] /// Casts number to isize -pub fn into_isize<T>(number: T) -> Result<isize> +pub fn into_isize<T>(number: &T) -> Result<isize> where T: NumCast, { @@ -460,22 +460,22 @@ mod tests { #[test] #[allow(clippy::float_cmp)] fn test_into_f64() { - assert_eq!(into_f64(1).unwrap(), 1.0 as f64); - assert_eq!(into_f64(1.9).unwrap(), 1.9 as f64); - assert_eq!(into_f64(-1.9).unwrap(), -1.9 as f64); - assert_eq!(into_f64(INFINITY as f32).unwrap(), INFINITY); - assert_eq!(into_f64(-INFINITY as f32).unwrap(), -INFINITY); + assert_eq!(into_f64(&1).unwrap(), 1.0 as f64); + assert_eq!(into_f64(&1.9).unwrap(), 1.9 as f64); + assert_eq!(into_f64(&-1.9).unwrap(), -1.9 as f64); + assert_eq!(into_f64(&(INFINITY as f32)).unwrap(), INFINITY); + assert_eq!(into_f64(&(-INFINITY as f32)).unwrap(), -INFINITY); } #[cfg(feature = "num-traits")] #[test] fn test_into_isize() { - assert_eq!(into_isize(1).unwrap(), 1 as isize); - assert_eq!(into_isize(1.9).unwrap(), 1 as isize); - assert_eq!(into_isize(-1.9).unwrap(), -1 as isize); - assert_eq!(into_isize(1.5 as f64).unwrap(), 1 as isize); - assert_eq!(into_isize(-1.5 as f64).unwrap(), -1 as isize); - match into_isize(INFINITY) { + assert_eq!(into_isize(&1).unwrap(), 1 as isize); + assert_eq!(into_isize(&1.9).unwrap(), 1 as isize); + assert_eq!(into_isize(&-1.9).unwrap(), -1 as isize); + assert_eq!(into_isize(&(1.5 as f64)).unwrap(), 1 as isize); + assert_eq!(into_isize(&(-1.5 as f64)).unwrap(), -1 as isize); + match into_isize(&INFINITY) { Err(Fmt(fmt::Error)) => {} _ => panic!("Should return error of type Err(Fmt(fmt::Error))"), }; |