Function regerror

Source
pub fn regerror(compiled_reg: &Regex, result: ErrorInt) -> RegexError
Expand description

Given a Regex struct and ErrorInt code, build a RegexError.

This is a thin wrapper around Regex::regerror.

§Arguments

  • compiled_reg: the compiled Regex that triggered the error.
  • result: the TRE result code, see reg_errcode_t.

WARNING: you should rarely need to call this directly.

§Returns

A RegexError object. If creating the object fails, there is no way to know for sure. Fortunately, this should be a nonexistent occurence if the API is used correctly.

§Examples

use std::ffi::c_char;
use std::ptr::null_mut;
use tre_regex::{{tre::{tre_regcomp, regex_t}}, Regex, regerror};

let mut compiled_reg: regex_t = Default::default();
let result = unsafe {
    tre_regcomp(&mut compiled_reg, b"[a\0".as_ptr() as *const c_char, 0)
};
let regex_error = regerror(&unsafe { Regex::new_from(compiled_reg) }, result);
println!("Error with regex: {regex_error}");