@@ -12,11 +12,11 @@ use std::collections::BTreeMap;
1212use std:: collections:: HashMap ;
1313use std:: fs:: { self , File } ;
1414use std:: path:: { Path , PathBuf } ;
15+ use std:: sync:: LazyLock ;
1516
1617use crate :: utils:: fs:: get_404_output_file;
1718use handlebars:: Handlebars ;
1819use log:: { debug, trace, warn} ;
19- use once_cell:: sync:: Lazy ;
2020use regex:: { Captures , Regex } ;
2121use serde_json:: json;
2222
@@ -664,7 +664,7 @@ fn make_data(
664664/// Goes through the rendered HTML, making sure all header tags have
665665/// an anchor respectively so people can link to sections directly.
666666fn build_header_links ( html : & str ) -> String {
667- static BUILD_HEADER_LINKS : Lazy < Regex > = Lazy :: new ( || {
667+ static BUILD_HEADER_LINKS : LazyLock < Regex > = LazyLock :: new ( || {
668668 Regex :: new ( r#"<h(\d)(?: id="([^"]+)")?(?: class="([^"]+)")?>(.*?)</h\d>"# ) . unwrap ( )
669669 } ) ;
670670 static IGNORE_CLASS : & [ & str ] = & [ "menu-title" ] ;
@@ -725,8 +725,8 @@ fn insert_link_into_header(
725725// ```
726726// This function replaces all commas by spaces in the code block classes
727727fn 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 ( ) ) ;
730730
731731 FIX_CODE_BLOCKS
732732 . replace_all ( html, |caps : & Captures < ' _ > | {
@@ -739,8 +739,8 @@ fn fix_code_blocks(html: &str) -> String {
739739 . into_owned ( )
740740}
741741
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 ( ) ) ;
744744
745745fn add_playground_pre (
746746 html : & str ,
@@ -808,8 +808,10 @@ fn add_playground_pre(
808808/// Modifies all `<code>` blocks to convert "hidden" lines and to wrap them in
809809/// a `<span class="boring">`.
810810fn 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 ( ) ) ;
813815
814816 CODE_BLOCK_RE
815817 . replace_all ( html, |caps : & Captures < ' _ > | {
@@ -850,7 +852,8 @@ fn hide_lines(html: &str, code_config: &Code) -> String {
850852}
851853
852854fn 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 ( ) ) ;
854857
855858 let mut result = String :: with_capacity ( content. len ( ) ) ;
856859 let mut lines = content. lines ( ) . peekable ( ) ;
0 commit comments