Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/regex/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1482,6 +1482,15 @@ impl Regex {
pub fn locations(&self) -> CaptureLocations {
self.capture_locations()
}

/// Return the total approximate heap memory, in bytes, used by this `Regex`.
///
/// Note that this value is unrelated to [`RegexBuilder::size_limit`], and can
/// in many cases exceed it.
Comment thread
BurntSushi marked this conversation as resolved.
Outdated
#[inline]
pub fn memory_usage(&self) -> usize {
self.meta.memory_usage() + self.pattern.len()
}
}

/// Represents a single match of a regex in a haystack.
Expand Down
9 changes: 9 additions & 0 deletions src/regex/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1481,6 +1481,15 @@ impl Regex {
pub fn locations(&self) -> CaptureLocations {
self.capture_locations()
}

/// Return the total approximate heap memory, in bytes, used by this `Regex`.
///
/// Note that this value is unrelated to [`RegexBuilder::size_limit`], and can
/// in many cases exceed it.
Comment thread
BurntSushi marked this conversation as resolved.
Outdated
#[inline]
pub fn memory_usage(&self) -> usize {
self.meta.memory_usage() + self.pattern.len()
}
}

/// Represents a single match of a regex in a haystack.
Expand Down