diff --git a/bindings/nodejs/src/lib.rs b/bindings/nodejs/src/lib.rs index f535af4..71461b2 100644 --- a/bindings/nodejs/src/lib.rs +++ b/bindings/nodejs/src/lib.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] + extern crate napi_derive; mod cep; diff --git a/core/src/cep.rs b/core/src/cep.rs index d6947e8..98fd8c9 100644 --- a/core/src/cep.rs +++ b/core/src/cep.rs @@ -313,8 +313,8 @@ mod tests { #[test] fn is_valid_accepts_valid_formatted() { - assert!(is_valid(&cep_sp().to_string())); - assert!(is_valid(&cep_rj().to_string())); + assert!(is_valid(cep_sp().as_ref())); + assert!(is_valid(cep_rj().as_ref())); } #[test] @@ -349,8 +349,8 @@ mod tests { #[test] fn strict_accepts_valid_formatted() { - assert!(is_valid_strict(&cep_sp().to_string()).is_ok()); - assert!(is_valid_strict(&cep_rj().to_string()).is_ok()); + assert!(is_valid_strict(cep_sp().as_ref()).is_ok()); + assert!(is_valid_strict(cep_rj().as_ref()).is_ok()); } #[test] @@ -543,9 +543,7 @@ mod tests { assert_eq!( cep.state(), Some(state), - "CEP {} should map to {:?}", - cep, - state + "CEP {cep} should map to {state:?}" ); } } diff --git a/core/src/cnpj.rs b/core/src/cnpj.rs index cd91e2d..57d79d2 100644 --- a/core/src/cnpj.rs +++ b/core/src/cnpj.rs @@ -770,7 +770,7 @@ mod tests { let result = is_valid("00623904000173"); // It's valid only if check digits match - let's compute if let Some((d1, d2)) = compute_check_digits("006239040001") { - let cnpj_str = alloc::format!("006239040001{}{}", d1, d2); + let cnpj_str = alloc::format!("006239040001{d1}{d2}"); assert!(is_valid(&cnpj_str)); let cnpj: Cnpj = cnpj_str.parse().unwrap(); assert!(cnpj.as_str().starts_with("00")); diff --git a/core/src/municipio.rs b/core/src/municipio.rs index 20d4713..3b521c6 100644 --- a/core/src/municipio.rs +++ b/core/src/municipio.rs @@ -27984,9 +27984,7 @@ mod tests { assert!( (a.state as u8) < (b.state as u8) || ((a.state as u8) == (b.state as u8) && a.name <= b.name), - "{} should come before {}", - a, - b + "{a} should come before {b}" ); } } @@ -27995,7 +27993,7 @@ mod tests { fn each_state_has_municipalities() { for &state in &crate::uf::ALL { let munis = Municipio::by_state(state); - assert!(!munis.is_empty(), "{:?} has no municipalities", state); + assert!(!munis.is_empty(), "{state:?} has no municipalities"); } } @@ -28004,8 +28002,7 @@ mod tests { for &code in &CAPITAL_CODES { assert!( Municipio::from_ibge_code(code).is_some(), - "Capital code {} not found", - code + "Capital code {code} not found" ); } } @@ -28021,7 +28018,7 @@ mod tests { #[test] fn from_ibge_code_sao_paulo() { - let sp = Municipio::from_ibge_code(3550308).unwrap(); + let sp = Municipio::from_ibge_code(3_550_308).unwrap(); assert_eq!(sp.name, "São Paulo"); assert_eq!(sp.state, State::SP); } @@ -28029,7 +28026,7 @@ mod tests { #[test] fn from_ibge_code_returns_none() { assert!(Municipio::from_ibge_code(0).is_none()); - assert!(Municipio::from_ibge_code(9999999).is_none()); + assert!(Municipio::from_ibge_code(9_999_999).is_none()); } #[test] @@ -28050,18 +28047,18 @@ mod tests { #[test] fn is_capital_correct() { - let sp = Municipio::from_ibge_code(3550308).unwrap(); + let sp = Municipio::from_ibge_code(3_550_308).unwrap(); assert!(sp.is_capital()); // Campinas is not a capital - let campinas = Municipio::from_ibge_code(3509502).unwrap(); + let campinas = Municipio::from_ibge_code(3_509_502).unwrap(); assert!(!campinas.is_capital()); } #[test] fn display_format() { use alloc::string::ToString; - let sp = Municipio::from_ibge_code(3550308).unwrap(); + let sp = Municipio::from_ibge_code(3_550_308).unwrap(); assert_eq!(sp.to_string(), "São Paulo/SP"); } diff --git a/core/tests/parity.rs b/core/tests/parity.rs index e2658a5..e187bbf 100644 --- a/core/tests/parity.rs +++ b/core/tests/parity.rs @@ -8,10 +8,10 @@ use std::collections::HashMap; use stdbr_core::{cep, cnpj, cpf, municipio, uf}; fn golden() -> Value { - let path = std::env::var("GOLDEN_JSON") - .unwrap_or_else(|_| "tests/parity/golden.json".to_string()); - let json = std::fs::read_to_string(&path) - .unwrap_or_else(|e| panic!("failed to read {path}: {e}")); + let path = + std::env::var("GOLDEN_JSON").unwrap_or_else(|_| "tests/parity/golden.json".to_string()); + let json = + std::fs::read_to_string(&path).unwrap_or_else(|e| panic!("failed to read {path}: {e}")); serde_json::from_str(&json).expect("failed to parse golden.json") }