Trait rust_regex_dsl_creator::ToDsl
source · pub trait ToDsl {
// Required method
fn to_dsl(&self) -> Result<String, Error>;
}
Expand description
Import this trait to enable the to_dsl
function for anything that implements the ToString trait.
Required Methods§
sourcefn to_dsl(&self) -> Result<String, Error>
fn to_dsl(&self) -> Result<String, Error>
This function (implemented by default for anything that implement the ToString trait) convert a regular expression to a DSL that can be used by the regex_dsl or create_capture macros. For example:
use rust_regex_dsl_creator::ToDsl;
let dsl = "[a-z]+[0-9]{2,3}$".to_dsl().unwrap();
assert_eq!(dsl, "concat {\n repeat {\n any_of {\n from: 'a', to: 'z',\n },\n },\n times {\n at_least: 2, at_most: 3,\n any_of {\n from: '0', to: '9',\n },\n },\n end_of_line,\n}\n")