once_cell -> std

This commit is contained in:
seth 2024-03-30 03:04:32 -04:00
parent a41a84fd2d
commit 90387c5a3b
No known key found for this signature in database
GPG key ID: D31BD0D494BBEE86
28 changed files with 157 additions and 153 deletions

View file

@ -1,8 +1,9 @@
use crate::api::paste_gg;
use std::sync::OnceLock;
use eyre::{OptionExt, Result};
use log::trace;
use once_cell::sync::Lazy;
use poise::serenity_prelude::Message;
use regex::Regex;
@ -10,11 +11,11 @@ pub struct PasteGG;
impl super::LogProvider for PasteGG {
async fn find_match(&self, message: &Message) -> Option<String> {
static REGEX: Lazy<Regex> =
Lazy::new(|| Regex::new(r"https://paste.gg/p/\w+/(\w+)").unwrap());
static REGEX: OnceLock<Regex> = OnceLock::new();
let regex = REGEX.get_or_init(|| Regex::new(r"https://paste.gg/p/\w+/(\w+)").unwrap());
trace!("Checking if message {} is a paste.gg paste", message.id);
super::get_first_capture(&REGEX, &message.content)
super::get_first_capture(regex, &message.content)
}
async fn fetch(&self, content: &str) -> Result<String> {