From 0f2e93e12ff9e06bb7219640e2c6447462eca9a6 Mon Sep 17 00:00:00 2001 From: Navneet Aman Date: Fri, 4 Oct 2024 11:09:57 +0530 Subject: [PATCH] rustfmt --- src/bytes.rs | 34 ++++++++++++++++++++++++++++------ src/ffi.rs | 8 +++++++- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/src/bytes.rs b/src/bytes.rs index d5daab4..63f52af 100644 --- a/src/bytes.rs +++ b/src/bytes.rs @@ -604,7 +604,12 @@ impl Regex { /// assert_eq!(&output, b"Hi john, wait you are not mike."); /// # Ok(()) }; example().unwrap() /// ``` - pub fn substitute(&self, subject: &[u8], replacement: &[u8], output: &mut Vec) -> Result{ + pub fn substitute( + &self, + subject: &[u8], + replacement: &[u8], + output: &mut Vec, + ) -> Result { self.code.substitute(subject, replacement, output, 0) } /// Replaces all the matches in `subject` with the `replacement`, @@ -622,10 +627,19 @@ impl Regex { /// assert_eq!(&output, b"Hi john, wait you are not john."); /// # Ok(()) }; example().unwrap() /// ``` - pub fn substitute_all(&self, subject: &[u8], replacement: &[u8], output: &mut Vec) -> Result{ - self.code.substitute(subject, replacement, output, pcre2_sys::PCRE2_SUBSTITUTE_GLOBAL) + pub fn substitute_all( + &self, + subject: &[u8], + replacement: &[u8], + output: &mut Vec, + ) -> Result { + self.code.substitute( + subject, + replacement, + output, + pcre2_sys::PCRE2_SUBSTITUTE_GLOBAL, + ) } - } /// Advanced or "lower level" search methods. @@ -1425,7 +1439,11 @@ mod tests { .unwrap(); let mut output = Vec::new(); re.substitute(hay.as_bytes(), b"42", &mut output).unwrap(); - assert_eq!(&output, "012345678942abcdefghijklmnopqrst😀👍🏼🎉auvwxyzABCKLMNOPQRSTUVWXYZ".as_bytes()); + assert_eq!( + &output, + "012345678942abcdefghijklmnopqrst😀👍🏼🎉auvwxyzABCKLMNOPQRSTUVWXYZ" + .as_bytes() + ); } #[test] fn test_substitute_all() { @@ -1444,6 +1462,10 @@ mod tests { .unwrap(); let mut output = Vec::new(); re.substitute_all(hay.as_bytes(), b"42", &mut output).unwrap(); - assert_eq!(&output, "012345678942abcdefghijklmnopqrst42auvwxyzABCKLMNOPQRSTUVWXYZ".as_bytes()); + assert_eq!( + &output, + "012345678942abcdefghijklmnopqrst42auvwxyzABCKLMNOPQRSTUVWXYZ" + .as_bytes() + ); } } diff --git a/src/ffi.rs b/src/ffi.rs index ed7fb3c..03482d6 100644 --- a/src/ffi.rs +++ b/src/ffi.rs @@ -261,7 +261,13 @@ impl Code { /// Substitute the replacement pattern in subject and put the output in /// output vec. Output vec is will be cleared before use. - pub(crate) fn substitute(&self, subject: &[u8], replacement: &[u8], output: &mut Vec, options: u32) -> Result{ + pub(crate) fn substitute( + &self, + subject: &[u8], + replacement: &[u8], + output: &mut Vec, + options: u32, + ) -> Result { output.clear(); let mut output_length = output.capacity(); let mut rc = unsafe {