Skip to content

Commit 74c7a35

Browse files
committed
♻️ Replace once_cell with std::sync::LazyLock
Replace once_cell::sync::Lazy with std::sync::LazyLock across codebase Update all static regex patterns and global state variables to use the std::sync::LazyLock type instead of the external once_cell dependency. This migration aligns with Rust's standard library improvements and reduces external dependencies. Additional changes: - Replace split().last() with split().next_back() for clarity - Use saturating_sub() instead of manual overflow protection - Replace deprecated io::ErrorKind::Other with io::Error::other() Affected modules include file analyzers, logger, UI components, and TUI application logic.
1 parent c4aa152 commit 74c7a35

File tree

19 files changed

+96
-112
lines changed

19 files changed

+96
-112
lines changed

src/changes/change_analyzer.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,17 @@ use crate::context::{ChangeType, RecentCommit};
33
use crate::git::GitRepo;
44
use anyhow::Result;
55
use git2::{Diff, Oid};
6-
use once_cell::sync::Lazy;
76
use regex::Regex;
87
use std::sync::Arc;
98

109
// Regex for extracting issue numbers (e.g., #123, GH-123)
11-
static ISSUE_RE: Lazy<Regex> = Lazy::new(|| {
10+
static ISSUE_RE: std::sync::LazyLock<Regex> = std::sync::LazyLock::new(|| {
1211
Regex::new(r"(?:#|GH-)(\d+)")
1312
.expect("Failed to compile issue number regex pattern - this is a bug")
1413
});
1514

1615
// Regex for extracting pull request numbers (e.g., PR #123, pull request 123)
17-
static PR_RE: Lazy<Regex> = Lazy::new(|| {
16+
static PR_RE: std::sync::LazyLock<Regex> = std::sync::LazyLock::new(|| {
1817
Regex::new(r"(?i)(?:pull request|PR)\s*#?(\d+)")
1918
.expect("Failed to compile pull request regex pattern - this is a bug")
2019
});

src/commit/relevance.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ impl Scorer for FileTypeScorer {
1414
fn score(&self, context: &CommitContext) -> HashMap<String, f32> {
1515
let mut scores = HashMap::new();
1616
for file in &context.staged_files {
17-
let score = match file.path.split('.').last() {
17+
let score = match file.path.split('.').next_back() {
1818
Some("rs") => 1.0,
1919
Some("js" | "ts") => 0.9,
2020
Some("py") => 0.8,

src/file_analyzers/c.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
11
use super::{FileAnalyzer, ProjectMetadata};
22
use crate::context::StagedFile;
3-
use once_cell::sync::Lazy;
43
use regex::Regex;
54
use std::collections::HashSet;
65

76
// Regex for extracting makefile version
8-
static MAKEFILE_VERSION_RE: Lazy<Regex> = Lazy::new(|| {
7+
static MAKEFILE_VERSION_RE: std::sync::LazyLock<Regex> = std::sync::LazyLock::new(|| {
98
Regex::new(r"VERSION\s*=\s*([^\s]+)").expect("Should compile: MAKEFILE_VERSION_RE")
109
});
1110
// Regex for extracting makefile dependencies
12-
static MAKEFILE_DEPENDENCY_RE: Lazy<Regex> = Lazy::new(|| {
11+
static MAKEFILE_DEPENDENCY_RE: std::sync::LazyLock<Regex> = std::sync::LazyLock::new(|| {
1312
Regex::new(r"LIBS\s*\+=\s*([^\s]+)").expect("Should compile: MAKEFILE_DEPENDENCY_RE")
1413
});
1514
// Regex for extracting modified C functions
16-
static C_FUNCTION_RE: Lazy<Regex> = Lazy::new(|| {
15+
static C_FUNCTION_RE: std::sync::LazyLock<Regex> = std::sync::LazyLock::new(|| {
1716
Regex::new(r"(?m)^[+-]\s*(?:static\s+)?(?:inline\s+)?(?:const\s+)?(?:volatile\s+)?(?:unsigned\s+)?(?:signed\s+)?(?:short\s+)?(?:long\s+)?(?:void|int|char|float|double|struct\s+\w+)\s+(\w+)\s*\(")
1817
.expect("Should compile: C_FUNCTION_RE")
1918
});
2019
// Regex for extracting modified C structs
21-
static C_STRUCT_RE: Lazy<Regex> =
22-
Lazy::new(|| Regex::new(r"(?m)^[+-]\s*struct\s+(\w+)").expect("Should compile: C_STRUCT_RE"));
20+
static C_STRUCT_RE: std::sync::LazyLock<Regex> =
21+
std::sync::LazyLock::new(|| Regex::new(r"(?m)^[+-]\s*struct\s+(\w+)").expect("Should compile: C_STRUCT_RE"));
2322
// Regex for checking C include changes
24-
static C_INCLUDE_RE: Lazy<Regex> =
25-
Lazy::new(|| Regex::new(r"(?m)^[+-]\s*#include").expect("Should compile: C_INCLUDE_RE"));
23+
static C_INCLUDE_RE: std::sync::LazyLock<Regex> =
24+
std::sync::LazyLock::new(|| Regex::new(r"(?m)^[+-]\s*#include").expect("Should compile: C_INCLUDE_RE"));
2625

2726
pub struct CAnalyzer;
2827

src/file_analyzers/cpp.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
11
use super::{FileAnalyzer, ProjectMetadata};
22
use crate::context::StagedFile;
3-
use once_cell::sync::Lazy;
43
use regex::Regex;
54
use std::collections::HashSet;
65

76
// Regex for extracting CMake project version
8-
static CMAKE_VERSION_RE: Lazy<Regex> = Lazy::new(|| {
7+
static CMAKE_VERSION_RE: std::sync::LazyLock<Regex> = std::sync::LazyLock::new(|| {
98
Regex::new(r"project\([^)]+\s+VERSION\s+([^\s)]+)").expect("Should compile: CMAKE_VERSION_RE")
109
});
1110
// Regex for extracting CMake dependencies (find_package)
12-
static CMAKE_DEPENDENCY_RE: Lazy<Regex> = Lazy::new(|| {
11+
static CMAKE_DEPENDENCY_RE: std::sync::LazyLock<Regex> = std::sync::LazyLock::new(|| {
1312
Regex::new(r"find_package\(([^)]+)\)").expect("Should compile: CMAKE_DEPENDENCY_RE")
1413
});
1514
// Regex for extracting modified C++ functions
16-
static CPP_FUNCTION_RE: Lazy<Regex> = Lazy::new(|| {
15+
static CPP_FUNCTION_RE: std::sync::LazyLock<Regex> = std::sync::LazyLock::new(|| {
1716
Regex::new(r"(?m)^[+-]\s*(?:static\s+)?(?:inline\s+)?(?:const\s+)?(?:volatile\s+)?(?:unsigned\s+)?(?:signed\s+)?(?:short\s+)?(?:long\s+)?(?:void|int|char|float|double|struct\s+\w+|class\s+\w+)\s+(\w+)\s*\(")
1817
.expect("Should compile: CPP_FUNCTION_RE")
1918
});
2019
// Regex for extracting modified C++ classes
21-
static CPP_CLASS_RE: Lazy<Regex> =
22-
Lazy::new(|| Regex::new(r"(?m)^[+-]\s*class\s+(\w+)").expect("Should compile: CPP_CLASS_RE"));
20+
static CPP_CLASS_RE: std::sync::LazyLock<Regex> =
21+
std::sync::LazyLock::new(|| Regex::new(r"(?m)^[+-]\s*class\s+(\w+)").expect("Should compile: CPP_CLASS_RE"));
2322
// Regex for checking C++ include changes
24-
static CPP_INCLUDE_RE: Lazy<Regex> =
25-
Lazy::new(|| Regex::new(r"(?m)^[+-]\s*#include").expect("Should compile: CPP_INCLUDE_RE"));
23+
static CPP_INCLUDE_RE: std::sync::LazyLock<Regex> =
24+
std::sync::LazyLock::new(|| Regex::new(r"(?m)^[+-]\s*#include").expect("Should compile: CPP_INCLUDE_RE"));
2625

2726
pub struct CppAnalyzer;
2827

src/file_analyzers/gradle.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,34 @@
11
use super::{FileAnalyzer, ProjectMetadata};
22
use crate::context::StagedFile;
3-
use once_cell::sync::Lazy;
43
use regex::Regex;
54
use std::collections::HashSet;
65

76
// Regex for checking dependency changes in Gradle diff
8-
static GRADLE_DEP_CHANGE_RE: Lazy<Regex> = Lazy::new(|| {
7+
static GRADLE_DEP_CHANGE_RE: std::sync::LazyLock<Regex> = std::sync::LazyLock::new(|| {
98
Regex::new(r"(?m)^[+-]\s*(implementation|api|testImplementation|compile)")
109
.expect("Should compile: GRADLE_DEP_CHANGE_RE")
1110
});
1211
// Regex for checking plugin changes in Gradle diff
13-
static GRADLE_PLUGIN_CHANGE_RE: Lazy<Regex> = Lazy::new(|| {
12+
static GRADLE_PLUGIN_CHANGE_RE: std::sync::LazyLock<Regex> = std::sync::LazyLock::new(|| {
1413
Regex::new(r"(?m)^[+-]\s*(plugins|apply plugin)")
1514
.expect("Should compile: GRADLE_PLUGIN_CHANGE_RE")
1615
});
1716
// Regex for checking task changes in Gradle diff
18-
static GRADLE_TASK_CHANGE_RE: Lazy<Regex> = Lazy::new(|| {
17+
static GRADLE_TASK_CHANGE_RE: std::sync::LazyLock<Regex> = std::sync::LazyLock::new(|| {
1918
Regex::new(r"(?m)^[+-]\s*task\s+").expect("Should compile: GRADLE_TASK_CHANGE_RE")
2019
});
2120
// Regex for extracting Gradle project version
22-
static GRADLE_VERSION_RE: Lazy<Regex> = Lazy::new(|| {
21+
static GRADLE_VERSION_RE: std::sync::LazyLock<Regex> = std::sync::LazyLock::new(|| {
2322
Regex::new(r#"version\s*=\s*['"](.*?)['"]"#).expect("Should compile: GRADLE_VERSION_RE")
2423
});
2524
// Regex for extracting Gradle dependencies
26-
static GRADLE_DEPENDENCY_RE: Lazy<Regex> = Lazy::new(|| {
25+
static GRADLE_DEPENDENCY_RE: std::sync::LazyLock<Regex> = std::sync::LazyLock::new(|| {
2726
Regex::new(r#"implementation\s+['"](.+?):(.+?):(.+?)['"]"#)
2827
.expect("Should compile: GRADLE_DEPENDENCY_RE")
2928
});
3029
// Regex for extracting Gradle plugins
31-
static GRADLE_PLUGIN_RE: Lazy<Regex> =
32-
Lazy::new(|| Regex::new(r#"id\s+['"](.+?)['"]"#).expect("Should compile: GRADLE_PLUGIN_RE"));
30+
static GRADLE_PLUGIN_RE: std::sync::LazyLock<Regex> =
31+
std::sync::LazyLock::new(|| Regex::new(r#"id\s+['"](.+?)['"]"#).expect("Should compile: GRADLE_PLUGIN_RE"));
3332

3433
pub struct GradleAnalyzer;
3534

src/file_analyzers/java.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,39 @@
11
use super::{FileAnalyzer, ProjectMetadata};
22
use crate::context::StagedFile;
3-
use once_cell::sync::Lazy;
43
use regex::Regex;
54
use std::collections::HashSet;
65

76
// Regex for extracting Maven version from pom.xml
8-
static MAVEN_VERSION_RE: Lazy<Regex> = Lazy::new(|| {
7+
static MAVEN_VERSION_RE: std::sync::LazyLock<Regex> = std::sync::LazyLock::new(|| {
98
Regex::new(r"<version>(.+?)</version>").expect("Should compile: MAVEN_VERSION_RE")
109
});
1110
// Regex for extracting Maven dependencies from pom.xml
12-
static MAVEN_DEPENDENCY_RE: Lazy<Regex> = Lazy::new(|| {
11+
static MAVEN_DEPENDENCY_RE: std::sync::LazyLock<Regex> = std::sync::LazyLock::new(|| {
1312
Regex::new(r"<dependency>\s*<groupId>(.+?)</groupId>\s*<artifactId>(.+?)</artifactId>")
1413
.expect("Should compile: MAVEN_DEPENDENCY_RE")
1514
});
1615
// Regex for extracting Gradle version from build.gradle
17-
static GRADLE_VERSION_RE: Lazy<Regex> = Lazy::new(|| {
16+
static GRADLE_VERSION_RE: std::sync::LazyLock<Regex> = std::sync::LazyLock::new(|| {
1817
Regex::new(r#"version\s*=\s*['"](.*?)['"]"#).expect("Should compile: GRADLE_VERSION_RE")
1918
});
2019
// Regex for extracting Gradle dependencies from build.gradle
21-
static GRADLE_DEPENDENCY_RE: Lazy<Regex> = Lazy::new(|| {
20+
static GRADLE_DEPENDENCY_RE: std::sync::LazyLock<Regex> = std::sync::LazyLock::new(|| {
2221
Regex::new(r#"implementation\s+['"](.+?):(.+?):"#)
2322
.expect("Should compile: GRADLE_DEPENDENCY_RE")
2423
});
2524
// Regex for extracting modified Java classes
26-
static JAVA_CLASS_RE: Lazy<Regex> = Lazy::new(|| {
25+
static JAVA_CLASS_RE: std::sync::LazyLock<Regex> = std::sync::LazyLock::new(|| {
2726
Regex::new(r"(?m)^[+-]\s*(public\s+|private\s+)?(class|interface|enum)\s+(\w+)")
2827
.expect("Should compile: JAVA_CLASS_RE")
2928
});
3029
// Regex for extracting modified Java methods
31-
static JAVA_METHOD_RE: Lazy<Regex> = Lazy::new(|| {
30+
static JAVA_METHOD_RE: std::sync::LazyLock<Regex> = std::sync::LazyLock::new(|| {
3231
Regex::new(r"(?m)^[+-]\s*(public|protected|private)?\s*\w+\s+(\w+)\s*\([^\)]*\)")
3332
.expect("Should compile: JAVA_METHOD_RE")
3433
});
3534
// Regex for checking Java import changes
36-
static JAVA_IMPORT_RE: Lazy<Regex> =
37-
Lazy::new(|| Regex::new(r"(?m)^[+-]\s*import\s+").expect("Should compile: JAVA_IMPORT_RE"));
35+
static JAVA_IMPORT_RE: std::sync::LazyLock<Regex> =
36+
std::sync::LazyLock::new(|| Regex::new(r"(?m)^[+-]\s*import\s+").expect("Should compile: JAVA_IMPORT_RE"));
3837

3938
pub struct JavaAnalyzer;
4039

src/file_analyzers/javascript.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
11
use super::{FileAnalyzer, ProjectMetadata};
22
use crate::context::StagedFile;
3-
use once_cell::sync::Lazy;
43
use regex::Regex;
54
use std::collections::HashSet;
65

76
// Regex for extracting modified JS/TS functions (function keyword or const arrow func)
8-
static JS_FUNCTION_RE: Lazy<Regex> = Lazy::new(|| {
7+
static JS_FUNCTION_RE: std::sync::LazyLock<Regex> = std::sync::LazyLock::new(|| {
98
Regex::new(r"(?m)^[+-]\s*(function\s+(\w+)|const\s+(\w+)\s*=\s*(\([^)]*\)\s*=>|\function))")
109
.expect("Should compile: JS_FUNCTION_RE")
1110
});
1211
// Regex for extracting modified JS/TS classes
13-
static JS_CLASS_RE: Lazy<Regex> =
14-
Lazy::new(|| Regex::new(r"(?m)^[+-]\s*class\s+(\w+)").expect("Should compile: JS_CLASS_RE"));
12+
static JS_CLASS_RE: std::sync::LazyLock<Regex> =
13+
std::sync::LazyLock::new(|| Regex::new(r"(?m)^[+-]\s*class\s+(\w+)").expect("Should compile: JS_CLASS_RE"));
1514
// Regex for checking JS/TS import/export changes
16-
static JS_IMPORT_EXPORT_RE: Lazy<Regex> = Lazy::new(|| {
15+
static JS_IMPORT_EXPORT_RE: std::sync::LazyLock<Regex> = std::sync::LazyLock::new(|| {
1716
Regex::new(r"(?m)^[+-]\s*(import|export)").expect("Should compile: JS_IMPORT_EXPORT_RE")
1817
});
1918
// Regex for extracting modified React class components
20-
static REACT_CLASS_COMPONENT_RE: Lazy<Regex> = Lazy::new(|| {
19+
static REACT_CLASS_COMPONENT_RE: std::sync::LazyLock<Regex> = std::sync::LazyLock::new(|| {
2120
Regex::new(r"(?m)^[+-]\s*class\s+(\w+)\s+extends\s+React\.Component")
2221
.expect("Should compile: REACT_CLASS_COMPONENT_RE")
2322
});
2423
// Regex for extracting modified React functional components
25-
static REACT_FUNC_COMPONENT_RE: Lazy<Regex> = Lazy::new(|| {
24+
static REACT_FUNC_COMPONENT_RE: std::sync::LazyLock<Regex> = std::sync::LazyLock::new(|| {
2625
Regex::new(r"(?m)^[+-]\s*(?:function\s+(\w+)|const\s+(\w+)\s*=)(?:\s*\([^)]*\))?\s*(?:=>)?\s*(?:\{[^}]*return|=>)\s*(?:<|\()").expect("Should compile: REACT_FUNC_COMPONENT_RE")
2726
});
2827

src/file_analyzers/json.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
use super::{FileAnalyzer, ProjectMetadata};
22
use crate::context::StagedFile;
33
use crate::log_debug;
4-
use once_cell::sync::Lazy;
54
use regex::Regex;
65
use std::collections::HashSet;
76

87
// Regex for extracting modified top-level JSON keys
9-
static JSON_TOP_LEVEL_KEY_RE: Lazy<Result<Regex, regex::Error>> =
10-
Lazy::new(|| Regex::new(r#"^[+-]\s*"(\w+)"\s*:"#));
8+
static JSON_TOP_LEVEL_KEY_RE: std::sync::LazyLock<Result<Regex, regex::Error>> =
9+
std::sync::LazyLock::new(|| Regex::new(r#"^[+-]\s*"(\w+)"\s*:"#));
1110
// Regex for checking JSON array changes
12-
static JSON_ARRAY_CHANGE_RE: Lazy<Regex> = Lazy::new(|| {
11+
static JSON_ARRAY_CHANGE_RE: std::sync::LazyLock<Regex> = std::sync::LazyLock::new(|| {
1312
Regex::new(r#"(?m)^[+-]\s*(?:"[^"]+"\s*:\s*)?\[|\s*[+-]\s*"[^"]+","#)
1413
.expect("Should compile: JSON_ARRAY_CHANGE_RE")
1514
});
1615
// Regex for checking nested JSON object changes
17-
static JSON_NESTED_OBJECT_CHANGE_RE: Lazy<Regex> = Lazy::new(|| {
16+
static JSON_NESTED_OBJECT_CHANGE_RE: std::sync::LazyLock<Regex> = std::sync::LazyLock::new(|| {
1817
Regex::new(r#"(?m)^[+-]\s*"[^"]+"\s*:\s*\{|\s*[+-]\s*"[^"]+"\s*:"#)
1918
.expect("Should compile: JSON_NESTED_OBJECT_CHANGE_RE")
2019
});

src/file_analyzers/kotlin.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,29 @@
11
use super::{FileAnalyzer, ProjectMetadata};
22
use crate::context::StagedFile;
3-
use once_cell::sync::Lazy;
43
use regex::Regex;
54
use std::collections::HashSet;
65

76
// Regex for extracting Gradle version from build.gradle.kts
8-
static GRADLE_KTS_VERSION_RE: Lazy<Regex> = Lazy::new(|| {
7+
static GRADLE_KTS_VERSION_RE: std::sync::LazyLock<Regex> = std::sync::LazyLock::new(|| {
98
Regex::new(r#"version\s*=\s*['"](.*?)['"]"#).expect("Should compile: GRADLE_KTS_VERSION_RE")
109
});
1110
// Regex for extracting Gradle dependencies from build.gradle.kts
12-
static GRADLE_KTS_DEPENDENCY_RE: Lazy<Regex> = Lazy::new(|| {
11+
static GRADLE_KTS_DEPENDENCY_RE: std::sync::LazyLock<Regex> = std::sync::LazyLock::new(|| {
1312
Regex::new(r#"implementation\s*\(\s*["'](.+?):(.+?):(.+?)["']\)"#)
1413
.expect("Should compile: GRADLE_KTS_DEPENDENCY_RE")
1514
});
1615
// Regex for extracting modified Kotlin classes/interfaces/objects
17-
static KOTLIN_CLASS_RE: Lazy<Regex> = Lazy::new(|| {
16+
static KOTLIN_CLASS_RE: std::sync::LazyLock<Regex> = std::sync::LazyLock::new(|| {
1817
Regex::new(r"(?m)^[+-]\s*(class|interface|object)\s+(\w+)")
1918
.expect("Should compile: KOTLIN_CLASS_RE")
2019
});
2120
// Regex for extracting modified Kotlin functions
22-
static KOTLIN_FUNCTION_RE: Lazy<Regex> = Lazy::new(|| {
21+
static KOTLIN_FUNCTION_RE: std::sync::LazyLock<Regex> = std::sync::LazyLock::new(|| {
2322
Regex::new(r"(?m)^[+-]\s*(fun)\s+(\w+)").expect("Should compile: KOTLIN_FUNCTION_RE")
2423
});
2524
// Regex for checking Kotlin import changes
26-
static KOTLIN_IMPORT_RE: Lazy<Regex> =
27-
Lazy::new(|| Regex::new(r"(?m)^[+-]\s*import\s+").expect("Should compile: KOTLIN_IMPORT_RE"));
25+
static KOTLIN_IMPORT_RE: std::sync::LazyLock<Regex> =
26+
std::sync::LazyLock::new(|| Regex::new(r"(?m)^[+-]\s*import\s+").expect("Should compile: KOTLIN_IMPORT_RE"));
2827

2928
pub struct KotlinAnalyzer;
3029

src/file_analyzers/markdown.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
11
use super::{FileAnalyzer, ProjectMetadata};
22
use crate::context::StagedFile;
3-
use once_cell::sync::Lazy;
43
use regex::Regex;
54

65
// Regex for extracting the first H1 header (potential project title)
7-
static MD_TITLE_RE: Lazy<Regex> =
8-
Lazy::new(|| Regex::new(r"(?m)^#\s+(.+)$").expect("Should compile: MD_TITLE_RE"));
6+
static MD_TITLE_RE: std::sync::LazyLock<Regex> =
7+
std::sync::LazyLock::new(|| Regex::new(r"(?m)^#\s+(.+)$").expect("Should compile: MD_TITLE_RE"));
98
// Regex for extracting version string (case-insensitive)
10-
static MD_VERSION_RE: Lazy<Regex> = Lazy::new(|| {
9+
static MD_VERSION_RE: std::sync::LazyLock<Regex> = std::sync::LazyLock::new(|| {
1110
Regex::new(r"(?i)version[:\s]+(\d+\.\d+\.\d+)").expect("Should compile: MD_VERSION_RE")
1211
});
1312
// Regex for extracting modified headers (H1-H6)
14-
static MD_MODIFIED_HEADER_RE: Lazy<Regex> = Lazy::new(|| {
13+
static MD_MODIFIED_HEADER_RE: std::sync::LazyLock<Regex> = std::sync::LazyLock::new(|| {
1514
Regex::new(r"[+-]\s*(#{1,6})\s+(.+)").expect("Should compile: MD_MODIFIED_HEADER_RE")
1615
});
1716
// Regex for checking list item changes
18-
static MD_LIST_CHANGE_RE: Lazy<Regex> =
19-
Lazy::new(|| Regex::new(r"[+-]\s*[-*+]\s+").expect("Should compile: MD_LIST_CHANGE_RE"));
17+
static MD_LIST_CHANGE_RE: std::sync::LazyLock<Regex> =
18+
std::sync::LazyLock::new(|| Regex::new(r"[+-]\s*[-*+]\s+").expect("Should compile: MD_LIST_CHANGE_RE"));
2019
// Regex for checking code block changes (```)
21-
static MD_CODE_BLOCK_CHANGE_RE: Lazy<Regex> =
22-
Lazy::new(|| Regex::new(r"[+-]\s*```").expect("Should compile: MD_CODE_BLOCK_CHANGE_RE"));
20+
static MD_CODE_BLOCK_CHANGE_RE: std::sync::LazyLock<Regex> =
21+
std::sync::LazyLock::new(|| Regex::new(r"[+-]\s*```").expect("Should compile: MD_CODE_BLOCK_CHANGE_RE"));
2322
// Regex for checking link changes ([text](url))
24-
static MD_LINK_CHANGE_RE: Lazy<Regex> =
25-
Lazy::new(|| Regex::new(r"[+-]\s*\[.+\]\(.+\)").expect("Should compile: MD_LINK_CHANGE_RE"));
23+
static MD_LINK_CHANGE_RE: std::sync::LazyLock<Regex> =
24+
std::sync::LazyLock::new(|| Regex::new(r"[+-]\s*\[.+\]\(.+\)").expect("Should compile: MD_LINK_CHANGE_RE"));
2625

2726
pub struct MarkdownAnalyzer;
2827

0 commit comments

Comments
 (0)