Index: src/utils.rs ================================================================== --- src/utils.rs +++ src/utils.rs @@ -1,25 +1,29 @@ use crate::Cursor; -use std::borrow::Cow; +use std::{ + borrow::Cow, + sync::LazyLock, +}; use html_escape::encode_text; -use lazy_static::lazy_static; use regex::{ Regex, RegexBuilder, }; use stacked_errors::{ bail, Result, }; -lazy_static! { - pub static ref RE_DOMAIN: Regex = Regex::new(r"^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$").expect("Invalid domain regex"); - pub static ref RE_CLOSING: Regex = RegexBuilder::new(r"") - .case_insensitive(true).build().expect("Invalid closing tag regex"); -} +pub static RE_DOMAIN: LazyLock = LazyLock::new(|| { + Regex::new(r"^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$").expect("Invalid domain regex") +}); +pub static RE_CLOSING: LazyLock = LazyLock::new(|| { + RegexBuilder::new(r"") + .case_insensitive(true).build().expect("Invalid closing tag regex") +}); /// Stores binary attachment data and metadata for Telegram messages. /// The data is wrapped in a `Cursor>` for efficient streaming, /// while `name` holds the filename or display name of the attachment. #[derive(Debug)]