This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change 11//! A helpful diagram for debugging dataflow problems.
22
33use std:: borrow:: Cow ;
4+ use std:: lazy:: SyncOnceCell ;
45use std:: { io, ops, str} ;
56
67use regex:: Regex ;
@@ -570,6 +571,13 @@ where
570571 }
571572}
572573
574+ macro_rules! regex {
575+ ( $re: literal $( , ) ?) => { {
576+ static RE : SyncOnceCell <regex:: Regex > = SyncOnceCell :: new( ) ;
577+ RE . get_or_init( || Regex :: new( $re) . unwrap( ) )
578+ } } ;
579+ }
580+
573581fn diff_pretty < T , C > ( new : T , old : T , ctxt : & C ) -> String
574582where
575583 T : DebugWithContext < C > ,
@@ -578,7 +586,7 @@ where
578586 return String :: new ( ) ;
579587 }
580588
581- let re = Regex :: new ( "\t ?\u{001f} ([+-])" ) . unwrap ( ) ;
589+ let re = regex ! ( "\t ?\u{001f} ([+-])" ) ;
582590
583591 let raw_diff = format ! ( "{:#?}" , DebugDiffWithAdapter { new, old, ctxt } ) ;
584592
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ Rust MIR: a lowered representation of Rust.
2727#![ feature( trait_alias) ]
2828#![ feature( option_expect_none) ]
2929#![ feature( or_patterns) ]
30+ #![ feature( once_cell) ]
3031#![ recursion_limit = "256" ]
3132
3233#[ macro_use]
You can’t perform that action at this time.
0 commit comments