-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dependency: replace lazy_static with OnceLock
Remove dependency on lazy_static and replace it with std::cell::OnceLock. Feature request #24
- Loading branch information
Showing
12 changed files
with
106 additions
and
134 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,16 +4,14 @@ | |
// | ||
// Copyright 2022-2024, John McNamara, [email protected] | ||
|
||
use regex::Regex; | ||
use crate::static_regex; | ||
|
||
// Convert XML string/doc into a vector for comparison testing. | ||
pub(crate) fn xml_to_vec(xml_string: &str) -> Vec<String> { | ||
lazy_static! { | ||
static ref ELEMENT_DIVIDES: Regex = Regex::new(r">\s*<").unwrap(); | ||
} | ||
let element_dividers = static_regex!(r">\s*<"); | ||
|
||
let mut xml_elements: Vec<String> = Vec::new(); | ||
let tokens: Vec<&str> = ELEMENT_DIVIDES.split(xml_string).collect(); | ||
let tokens: Vec<&str> = element_dividers.split(xml_string).collect(); | ||
|
||
for token in &tokens { | ||
let mut element = token.trim().to_string(); | ||
|
@@ -35,12 +33,10 @@ pub(crate) fn xml_to_vec(xml_string: &str) -> Vec<String> { | |
// Convert VML string/doc into a vector for comparison testing. Excel VML tends | ||
// to be less structured than other XML so it needs more massaging. | ||
pub(crate) fn vml_to_vec(vml_string: &str) -> Vec<String> { | ||
lazy_static! { | ||
static ref WHITESPACE: Regex = Regex::new(r"\s+").unwrap(); | ||
} | ||
let whitespace = static_regex!(r"\s+"); | ||
|
||
let mut vml_string = vml_string.replace(['\r', '\n'], ""); | ||
vml_string = WHITESPACE.replace_all(&vml_string, " ").into(); | ||
vml_string = whitespace.replace_all(&vml_string, " ").into(); | ||
|
||
vml_string = vml_string | ||
.replace("; ", ";") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
a796a24
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!