@@ -7,7 +7,7 @@ use ipld_core::cid;
7
7
use langtag:: { LanguageTag , LanguageTagBuf } ;
8
8
use regex:: Regex ;
9
9
use serde:: { de:: Error , Deserialize , Deserializer , Serialize , Serializer } ;
10
- use std:: { cell :: OnceCell , cmp, ops:: Deref , str:: FromStr } ;
10
+ use std:: { cmp, ops:: Deref , str:: FromStr , sync :: OnceLock } ;
11
11
12
12
/// Common trait implementations for Lexicon string formats that are newtype wrappers
13
13
/// around `String`.
@@ -213,7 +213,7 @@ impl FromStr for Datetime {
213
213
// datetimes to the subset that is also valid under ISO 8601. Apply a regex that
214
214
// validates enough of the relevant ISO 8601 format that the RFC 3339 parser can
215
215
// do the rest.
216
- const RE_ISO_8601 : OnceCell < Regex > = OnceCell :: new ( ) ;
216
+ static RE_ISO_8601 : OnceLock < Regex > = OnceLock :: new ( ) ;
217
217
if RE_ISO_8601
218
218
. get_or_init ( || Regex :: new ( r"^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\.[0-9]+)?(Z|(\+[0-9]{2}|\-[0-9][1-9]):[0-9]{2})$" ) . unwrap ( ) )
219
219
. is_match ( s)
@@ -267,7 +267,7 @@ impl Did {
267
267
#[ allow( clippy:: borrow_interior_mutable_const, clippy:: declare_interior_mutable_const) ]
268
268
/// Parses a `Did` from the given string.
269
269
pub fn new ( did : String ) -> Result < Self , & ' static str > {
270
- const RE_DID : OnceCell < Regex > = OnceCell :: new ( ) ;
270
+ static RE_DID : OnceLock < Regex > = OnceLock :: new ( ) ;
271
271
272
272
// https://atproto.com/specs/did#at-protocol-did-identifier-syntax
273
273
if did. len ( ) > 2048 {
@@ -305,7 +305,7 @@ impl Handle {
305
305
#[ allow( clippy:: borrow_interior_mutable_const, clippy:: declare_interior_mutable_const) ]
306
306
/// Parses a `Handle` from the given string.
307
307
pub fn new ( handle : String ) -> Result < Self , & ' static str > {
308
- const RE_HANDLE : OnceCell < Regex > = OnceCell :: new ( ) ;
308
+ static RE_HANDLE : OnceLock < Regex > = OnceLock :: new ( ) ;
309
309
310
310
// https://atproto.com/specs/handle#handle-identifier-syntax
311
311
if handle. len ( ) > 253 {
@@ -338,7 +338,7 @@ impl Nsid {
338
338
#[ allow( clippy:: borrow_interior_mutable_const, clippy:: declare_interior_mutable_const) ]
339
339
/// Parses an NSID from the given string.
340
340
pub fn new ( nsid : String ) -> Result < Self , & ' static str > {
341
- const RE_NSID : OnceCell < Regex > = OnceCell :: new ( ) ;
341
+ static RE_NSID : OnceLock < Regex > = OnceLock :: new ( ) ;
342
342
343
343
// https://atproto.com/specs/handle#handle-identifier-syntax
344
344
if nsid. len ( ) > 317 {
@@ -420,7 +420,7 @@ impl Tid {
420
420
#[ allow( clippy:: borrow_interior_mutable_const, clippy:: declare_interior_mutable_const) ]
421
421
/// Parses a `TID` from the given string.
422
422
pub fn new ( tid : String ) -> Result < Self , & ' static str > {
423
- const RE_TID : OnceCell < Regex > = OnceCell :: new ( ) ;
423
+ static RE_TID : OnceLock < Regex > = OnceLock :: new ( ) ;
424
424
425
425
if tid. len ( ) != 13 {
426
426
Err ( "TID must be 13 characters" )
@@ -452,7 +452,7 @@ impl RecordKey {
452
452
#[ allow( clippy:: borrow_interior_mutable_const, clippy:: declare_interior_mutable_const) ]
453
453
/// Parses a `Record Key` from the given string.
454
454
pub fn new ( s : String ) -> Result < Self , & ' static str > {
455
- const RE_RKEY : OnceCell < Regex > = OnceCell :: new ( ) ;
455
+ static RE_RKEY : OnceLock < Regex > = OnceLock :: new ( ) ;
456
456
457
457
if [ "." , ".." ] . contains ( & s. as_str ( ) ) {
458
458
Err ( "Disallowed rkey" )
0 commit comments