fix: use regex crate in codegen

This commit is contained in:
ThetaDev 2023-02-18 20:42:00 +01:00
parent c80ccf66ce
commit 2a4233e5d5
3 changed files with 4 additions and 5 deletions

View file

@ -2,10 +2,10 @@ use std::collections::{HashMap, HashSet};
use std::{collections::BTreeMap, fs::File, io::BufReader, path::Path};
use anyhow::{Context, Result};
use fancy_regex::Regex;
use futures::{stream, StreamExt};
use once_cell::sync::Lazy;
use path_macro::path;
use regex::Regex;
use reqwest::{header, Client};
use rustypipe::param::{locale::LANGUAGES, Language};
use serde::Deserialize;
@ -139,7 +139,6 @@ pub fn write_samples_to_dict(project_root: &Path) {
.find_map(|(mag, (txt, _))| {
let point = POINT_REGEX
.captures(txt)
.unwrap()
.map(|c| c.get(1).unwrap().as_str());
if let Some(point) = point {

View file

@ -1,8 +1,8 @@
use std::fmt::Write;
use std::path::Path;
use fancy_regex::Regex;
use once_cell::sync::Lazy;
use regex::Regex;
use rustypipe::timeago::TimeUnit;
use crate::util;
@ -11,7 +11,7 @@ const TARGET_PATH: &str = "src/util/dictionary.rs";
fn parse_tu(tu: &str) -> (u8, Option<TimeUnit>) {
static TU_PATTERN: Lazy<Regex> = Lazy::new(|| Regex::new(r"^(\d*)(\w?)$").unwrap());
match TU_PATTERN.captures(tu).unwrap() {
match TU_PATTERN.captures(tu) {
Some(cap) => (
cap.get(1).unwrap().as_str().parse().unwrap_or(1),
match cap.get(2).unwrap().as_str() {