From 7a3ae5d5fdc8a1bd0b687132490cda8bb5aa10a6 Mon Sep 17 00:00:00 2001 From: freekeeperlzt Date: Sun, 25 Sep 2022 00:36:24 -0700 Subject: [PATCH] cargo fmt --- regex-capi/src/error.rs | 9 +++++---- regex-capi/src/rure.rs | 19 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/regex-capi/src/error.rs b/regex-capi/src/error.rs index 2ca3fae..01d85c7 100644 --- a/regex-capi/src/error.rs +++ b/regex-capi/src/error.rs @@ -22,15 +22,16 @@ pub enum ErrorKind { impl Error { pub fn new(kind: ErrorKind) -> Error { - Error { message: None, kind: kind } + Error { + message: None, + kind: kind, + } } pub fn is_err(&self) -> bool { match self.kind { ErrorKind::None => false, - ErrorKind::Str(_) | ErrorKind::Regex(_) | ErrorKind::Nul(_) => { - true - } + ErrorKind::Str(_) | ErrorKind::Regex(_) | ErrorKind::Nul(_) => true, } } } diff --git a/regex-capi/src/rure.rs b/regex-capi/src/rure.rs index 53cc5f9..cb4c702 100644 --- a/regex-capi/src/rure.rs +++ b/regex-capi/src/rure.rs @@ -70,7 +70,10 @@ impl Deref for RegexSet { impl Default for Options { fn default() -> Options { - Options { size_limit: 10 * (1 << 20), dfa_size_limit: 2 * (1 << 20) } + Options { + size_limit: 10 * (1 << 20), + dfa_size_limit: 2 * (1 << 20), + } } } @@ -595,11 +598,7 @@ ffi_fn! { /// This should ideally be exposed, but it needs API design work. In /// particular, this should not return a C string, but a `const uint8_t *` /// instead, since it may contain a NUL byte. -fn rure_escape( - pattern: *const u8, - length: size_t, - error: *mut Error, -) -> *const c_char { +fn rure_escape(pattern: *const u8, length: size_t, error: *mut Error) -> *const c_char { let pat: &[u8] = unsafe { slice::from_raw_parts(pattern, length) }; let str_pat = match str::from_utf8(pat) { Ok(val) => val, @@ -650,7 +649,7 @@ ffi_fn! { }, }; c_esc_pat.into_raw() as *const c_char - + } } @@ -676,7 +675,7 @@ ffi_fn! { }, }; c_esc_pat.into_raw() as *const c_char - + } } @@ -684,7 +683,7 @@ ffi_fn! { * Simple way to use regex */ - ffi_fn! { +ffi_fn! { fn rure_new( pattern: *const u8, length: size_t, @@ -721,4 +720,4 @@ ffi_fn! { }).is_some() } -} \ No newline at end of file +} -- Gitee