switch to lazy_regex

This commit is contained in:
Quaternions 2023-11-18 15:47:54 -08:00
parent 43115cbac6
commit a386f90f51
3 changed files with 26 additions and 3 deletions

25
Cargo.lock generated
View File

@ -609,6 +609,29 @@ dependencies = [
"wasm-bindgen", "wasm-bindgen",
] ]
[[package]]
name = "lazy-regex"
version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d12be4595afdf58bd19e4a9f4e24187da2a66700786ff660a418e9059937a4c"
dependencies = [
"lazy-regex-proc_macros",
"once_cell",
"regex",
]
[[package]]
name = "lazy-regex-proc_macros"
version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "44bcd58e6c97a7fcbaffcdc95728b393b8d98933bfadad49ed4097845b57ef0b"
dependencies = [
"proc-macro2",
"quote",
"regex",
"syn 2.0.38",
]
[[package]] [[package]]
name = "lazy_static" name = "lazy_static"
version = "1.4.0" version = "1.4.0"
@ -688,11 +711,11 @@ dependencies = [
"flate2", "flate2",
"image", "image",
"image_dds", "image_dds",
"lazy-regex",
"rbx_binary", "rbx_binary",
"rbx_dom_weak", "rbx_dom_weak",
"rbx_reflection_database", "rbx_reflection_database",
"rbx_xml", "rbx_xml",
"regex",
] ]
[[package]] [[package]]

View File

@ -11,11 +11,11 @@ clap = { version = "4.4.2", features = ["derive"] }
flate2 = "1.0.27" flate2 = "1.0.27"
image = "0.24.7" image = "0.24.7"
image_dds = "0.1.1" image_dds = "0.1.1"
lazy-regex = "3.1.0"
rbx_binary = "0.7.1" rbx_binary = "0.7.1"
rbx_dom_weak = "2.5.0" rbx_dom_weak = "2.5.0"
rbx_reflection_database = "0.2.7" rbx_reflection_database = "0.2.7"
rbx_xml = "0.13.1" rbx_xml = "0.13.1"
regex = "1.9.5"
#[profile.release] #[profile.release]
#lto = true #lto = true

View File

@ -264,7 +264,7 @@ struct RobloxAssetIdParseErr;
impl std::str::FromStr for RobloxAssetId { impl std::str::FromStr for RobloxAssetId {
type Err=RobloxAssetIdParseErr; type Err=RobloxAssetIdParseErr;
fn from_str(s: &str) -> Result<Self, Self::Err>{ fn from_str(s: &str) -> Result<Self, Self::Err>{
let regman=regex::Regex::new(r"(\d+)$").unwrap(); let regman=lazy_regex::regex!(r"(\d+)$");
if let Some(captures) = regman.captures(s) { if let Some(captures) = regman.captures(s) {
if captures.len()==2{//captures[0] is all captures concatenated, and then each individual capture if captures.len()==2{//captures[0] is all captures concatenated, and then each individual capture
if let Ok(id) = captures[0].parse::<u64>() { if let Ok(id) = captures[0].parse::<u64>() {