From f80101153e62663f9b65d992288a02bb2326f84e Mon Sep 17 00:00:00 2001 From: poz Date: Sat, 16 Aug 2025 02:39:38 +0200 Subject: [PATCH 1/3] derive `Copy` and `Clone` for `ErrorKind` --- src/err.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/err.rs b/src/err.rs index 6396b8c..f249eba 100644 --- a/src/err.rs +++ b/src/err.rs @@ -29,7 +29,7 @@ impl BindingErrorCode { /// Type of error: `Binding` (see [`BindingErrorCode`]), or `Tre` /// /// See the TRE documentation for more information on valid error codes for `Tre`. -#[derive(Debug, PartialEq, Eq)] +#[derive(Debug, Copy, Clone, PartialEq, Eq)] pub enum ErrorKind { /// Binding-specific error Binding(BindingErrorCode), From a9fea82aaee57a5c1b3d636639fdabf168bd0bf6 Mon Sep 17 00:00:00 2001 From: poz Date: Sat, 16 Aug 2025 02:40:06 +0200 Subject: [PATCH 2/3] derive `Clone` for `RegexError` --- src/err.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/err.rs b/src/err.rs index f249eba..0356e5b 100644 --- a/src/err.rs +++ b/src/err.rs @@ -39,7 +39,7 @@ pub enum ErrorKind { } /// Error type returned in results -#[derive(Debug, PartialEq, Eq)] +#[derive(Debug, Clone, PartialEq, Eq)] pub struct RegexError { /// Kind of error pub kind: ErrorKind, From ab3dfc5fc9770cf1630fd13fc12235b63b8d4065 Mon Sep 17 00:00:00 2001 From: poz Date: Sun, 24 Aug 2025 22:31:38 +0200 Subject: [PATCH 3/3] fix char casts in ffi calls --- src/approx.rs | 4 ++-- src/exec.rs | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/approx.rs b/src/approx.rs index 2946165..a3fa08b 100644 --- a/src/approx.rs +++ b/src/approx.rs @@ -2,7 +2,7 @@ // See LICENSE file in the project root for full license text. use std::borrow::Cow; -use std::ffi::c_int; +use std::ffi::{c_char, c_int}; use std::hint::unreachable_unchecked; use crate::{ @@ -372,7 +372,7 @@ impl Regex { let result = unsafe { tre::tre_reganexec( compiled_reg_obj, - data.as_ptr().cast::(), + data.as_ptr().cast::(), data.len(), &mut amatch, *params.get(), diff --git a/src/exec.rs b/src/exec.rs index 55e2cc7..543413e 100644 --- a/src/exec.rs +++ b/src/exec.rs @@ -2,6 +2,7 @@ // See LICENSE file in the project root for full license text. use std::borrow::Cow; +use std::ffi::c_char; use std::hint::unreachable_unchecked; use crate::{err::{BindingErrorCode, ErrorKind, RegexError, Result}, flags::RegexecFlags, tre, Regex}; @@ -169,7 +170,7 @@ impl Regex { let result = unsafe { tre::tre_regnexec( compiled_reg_obj, - data.as_ptr().cast::(), + data.as_ptr().cast::(), data.len(), nmatches, match_vec.as_mut_ptr(),