@@ -12,11 +12,11 @@ use std::collections::BTreeMap;
12
12
use std:: collections:: HashMap ;
13
13
use std:: fs:: { self , File } ;
14
14
use std:: path:: { Path , PathBuf } ;
15
+ use std:: sync:: LazyLock ;
15
16
16
17
use crate :: utils:: fs:: get_404_output_file;
17
18
use handlebars:: Handlebars ;
18
19
use log:: { debug, trace, warn} ;
19
- use once_cell:: sync:: Lazy ;
20
20
use regex:: { Captures , Regex } ;
21
21
use serde_json:: json;
22
22
@@ -664,7 +664,7 @@ fn make_data(
664
664
/// Goes through the rendered HTML, making sure all header tags have
665
665
/// an anchor respectively so people can link to sections directly.
666
666
fn build_header_links ( html : & str ) -> String {
667
- static BUILD_HEADER_LINKS : Lazy < Regex > = Lazy :: new ( || {
667
+ static BUILD_HEADER_LINKS : LazyLock < Regex > = LazyLock :: new ( || {
668
668
Regex :: new ( r#"<h(\d)(?: id="([^"]+)")?(?: class="([^"]+)")?>(.*?)</h\d>"# ) . unwrap ( )
669
669
} ) ;
670
670
static IGNORE_CLASS : & [ & str ] = & [ "menu-title" ] ;
@@ -725,8 +725,8 @@ fn insert_link_into_header(
725
725
// ```
726
726
// This function replaces all commas by spaces in the code block classes
727
727
fn fix_code_blocks ( html : & str ) -> String {
728
- static FIX_CODE_BLOCKS : Lazy < Regex > =
729
- Lazy :: new ( || Regex :: new ( r##"<code([^>]+)class="([^"]+)"([^>]*)>"## ) . unwrap ( ) ) ;
728
+ static FIX_CODE_BLOCKS : LazyLock < Regex > =
729
+ LazyLock :: new ( || Regex :: new ( r##"<code([^>]+)class="([^"]+)"([^>]*)>"## ) . unwrap ( ) ) ;
730
730
731
731
FIX_CODE_BLOCKS
732
732
. replace_all ( html, |caps : & Captures < ' _ > | {
@@ -739,8 +739,8 @@ fn fix_code_blocks(html: &str) -> String {
739
739
. into_owned ( )
740
740
}
741
741
742
- static CODE_BLOCK_RE : Lazy < Regex > =
743
- Lazy :: new ( || Regex :: new ( r##"((?s)<code[^>]?class="([^"]+)".*?>(.*?)</code>)"## ) . unwrap ( ) ) ;
742
+ static CODE_BLOCK_RE : LazyLock < Regex > =
743
+ LazyLock :: new ( || Regex :: new ( r##"((?s)<code[^>]?class="([^"]+)".*?>(.*?)</code>)"## ) . unwrap ( ) ) ;
744
744
745
745
fn add_playground_pre (
746
746
html : & str ,
@@ -808,8 +808,10 @@ fn add_playground_pre(
808
808
/// Modifies all `<code>` blocks to convert "hidden" lines and to wrap them in
809
809
/// a `<span class="boring">`.
810
810
fn hide_lines ( html : & str , code_config : & Code ) -> String {
811
- static LANGUAGE_REGEX : Lazy < Regex > = Lazy :: new ( || Regex :: new ( r"\blanguage-(\w+)\b" ) . unwrap ( ) ) ;
812
- static HIDELINES_REGEX : Lazy < Regex > = Lazy :: new ( || Regex :: new ( r"\bhidelines=(\S+)" ) . unwrap ( ) ) ;
811
+ static LANGUAGE_REGEX : LazyLock < Regex > =
812
+ LazyLock :: new ( || Regex :: new ( r"\blanguage-(\w+)\b" ) . unwrap ( ) ) ;
813
+ static HIDELINES_REGEX : LazyLock < Regex > =
814
+ LazyLock :: new ( || Regex :: new ( r"\bhidelines=(\S+)" ) . unwrap ( ) ) ;
813
815
814
816
CODE_BLOCK_RE
815
817
. replace_all ( html, |caps : & Captures < ' _ > | {
@@ -850,7 +852,8 @@ fn hide_lines(html: &str, code_config: &Code) -> String {
850
852
}
851
853
852
854
fn hide_lines_rust ( content : & str ) -> String {
853
- static BORING_LINES_REGEX : Lazy < Regex > = Lazy :: new ( || Regex :: new ( r"^(\s*)#(.?)(.*)$" ) . unwrap ( ) ) ;
855
+ static BORING_LINES_REGEX : LazyLock < Regex > =
856
+ LazyLock :: new ( || Regex :: new ( r"^(\s*)#(.?)(.*)$" ) . unwrap ( ) ) ;
854
857
855
858
let mut result = String :: with_capacity ( content. len ( ) ) ;
856
859
let mut lines = content. lines ( ) . peekable ( ) ;
0 commit comments