FIX: Apply copilot hints

This commit is contained in:
Nicolás Hatcher
2025-07-03 20:33:39 +02:00
committed by Nicolás Hatcher Andrés
parent b1327d83d4
commit 689f55effa
2 changed files with 4 additions and 3 deletions

View File

@@ -5,11 +5,12 @@ use super::Node;
use regex::Regex; use regex::Regex;
use std::sync::OnceLock; use std::sync::OnceLock;
static RE: OnceLock<Regex> = OnceLock::new(); static RANGE_REFERENCE_REGEX: OnceLock<Regex> = OnceLock::new();
#[allow(clippy::expect_used)] #[allow(clippy::expect_used)]
fn get_re() -> &'static Regex { fn get_re() -> &'static Regex {
RE.get_or_init(|| Regex::new(r":[A-Z]*[0-9]*$").expect("Regex is known to be valid")) RANGE_REFERENCE_REGEX
.get_or_init(|| Regex::new(r":[A-Z]*[0-9]*$").expect("Regex is known to be valid"))
} }
fn is_range_reference(s: &str) -> bool { fn is_range_reference(s: &str) -> bool {

View File

@@ -76,5 +76,5 @@ fn get_locales() -> &'static HashMap<String, Locale> {
pub fn get_locale(id: &str) -> Result<&Locale, String> { pub fn get_locale(id: &str) -> Result<&Locale, String> {
get_locales() get_locales()
.get(id) .get(id)
.ok_or_else(|| "Invalid locale".to_string()) .ok_or_else(|| format!("Invalid locale: '{id}'"))
} }