Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make matches()/exec() work with non-mut pcre #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
10 changes: 5 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ impl Pcre {
/// If a regular expression will be used often, it might be worth studying it to possibly
/// speed up matching. See the [study()](#method.study) method.
#[inline]
pub fn exec<'a, 'p>(&'p mut self, subject: &'a str) -> Option<Match<'a>> {
pub fn exec<'a, 'p>(&'p self, subject: &'a str) -> Option<Match<'a>> {
self.exec_from(subject, 0)
}

Expand All @@ -411,7 +411,7 @@ impl Pcre {
/// If a regular expression will be used often, it might be worth studying it to possibly
/// speed up matching. See the [study()](#method.study) method.
#[inline]
pub fn exec_from<'a, 'p>(&'p mut self, subject: &'a str, startoffset: usize) -> Option<Match<'a>> {
pub fn exec_from<'a, 'p>(&'p self, subject: &'a str, startoffset: usize) -> Option<Match<'a>> {
let no_options: EnumSet<ExecOption> = EnumSet::new();
self.exec_from_with_options(subject, startoffset, &no_options)
}
Expand All @@ -436,7 +436,7 @@ impl Pcre {
/// If a regular expression will be used often, it might be worth studying it to possibly
/// speed up matching. See the [study()](#method.study) method.
#[inline]
pub fn exec_from_with_options<'a, 'p>(&'p mut self, subject: &'a str, startoffset: usize, options: &EnumSet<ExecOption>) -> Option<Match<'a>> {
pub fn exec_from_with_options<'a, 'p>(&'p self, subject: &'a str, startoffset: usize, options: &EnumSet<ExecOption>) -> Option<Match<'a>> {
let ovecsize = (self.capture_count_ + 1) * 3;
let mut ovector = vec![0 as c_int; ovecsize as usize];

Expand Down Expand Up @@ -496,7 +496,7 @@ impl Pcre {
/// # Argument
/// * `subject` - The subject string.
#[inline]
pub fn matches<'a, 'p>(&'p mut self, subject: &'a str) -> MatchIterator<'a, 'p> {
pub fn matches<'a, 'p>(&'p self, subject: &'a str) -> MatchIterator<'a, 'p> {
let no_options: EnumSet<ExecOption> = EnumSet::new();
self.matches_with_options(subject, &no_options)
}
Expand All @@ -509,7 +509,7 @@ impl Pcre {
/// * `options` - Bitwise-OR'd matching options. See the libpcre manpages, `man 3 pcre_exec`,
/// for more information.
#[inline]
pub fn matches_with_options<'a, 'p>(&'p mut self, subject: &'a str, options: &EnumSet<ExecOption>) -> MatchIterator<'a, 'p> {
pub fn matches_with_options<'a, 'p>(&'p self, subject: &'a str, options: &EnumSet<ExecOption>) -> MatchIterator<'a, 'p> {
unsafe {
let ovecsize = (self.capture_count_ + 1) * 3;
MatchIterator {
Expand Down