Skip to content

Commit dc9a2f4

Browse files
committed
feat(string): add Debug for Regex
Manual @debug.Debug impl renders as <Regex: <pattern>>.
1 parent 4614523 commit dc9a2f4

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

string/pkg.generated.mbti

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ pub struct Regex {
3434

3535
fn new(StringView) -> Regex raise
3636
}
37+
pub impl @debug.Debug for Regex
3738
pub fn Regex::capture(Self, String) -> Self
3839
pub fn Regex::execute(Self, StringView, last_index? : Int) -> MatchResult?
3940
pub fn Regex::find(Self, StringView) -> Iter[MatchResult]

string/regex.mbt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ const MAX_REPEAT_QUANTIFIER = 256
2727
///|
2828
using @debug {trait Debug, type Repr}
2929

30+
///|
31+
pub impl Debug for Regex with to_repr(self) {
32+
Repr::opaque_("Regex", @debug.to_repr(self.pat))
33+
}
34+
3035
///|
3136
/// Result of one successful match produced by `Regex::execute`.
3237
struct MatchResult {

0 commit comments

Comments
 (0)