Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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 does not have a defined relationship to
/// to [`RegexBuilder::size_limit`].
#[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 does not have a defined relationship to
/// to [`RegexBuilder::size_limit`].
#[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