Add i32/u32 suffix for numeric literals in 04_traits/01_trait (#20)

Without an explicit suffix, the compiler is able to use the i32
implementation without the need for an u32 implementation.
This commit is contained in:
Fangyi Zhou 2024-05-22 10:04:04 +01:00 committed by GitHub
parent e5eee2e83c
commit 5bb9333ae9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -9,15 +9,15 @@ mod tests {
#[test] #[test]
fn test_u32_is_even() { fn test_u32_is_even() {
assert!(42.is_even()); assert!(42u32.is_even());
assert!(!43.is_even()); assert!(!43u32.is_even());
} }
#[test] #[test]
fn test_i32_is_even() { fn test_i32_is_even() {
assert!(42.is_even()); assert!(42i32.is_even());
assert!(!43.is_even()); assert!(!43i32.is_even());
assert!(0.is_even()); assert!(0i32.is_even());
assert!(!(-1).is_even()); assert!(!(-1i32).is_even());
} }
} }