From 86a33462d80c48cf3d534da0759d2b2ea5ddce5f Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Mon, 15 Jul 2019 11:50:38 -0700 Subject: [PATCH] feat: add `FromStr` impl for `Pattern` Signed-off-by: Eliza Weisman --- src/lib.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index c4dd46e..3f97211 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,7 +1,7 @@ //! Regex matchers on character and byte streams. use regex_automata::{DenseDFA, SparseDFA, StateID, DFA}; -use std::{fmt, io, marker::PhantomData}; +use std::{fmt, io, marker::PhantomData, str::FromStr}; pub use regex_automata::Error; @@ -34,6 +34,13 @@ impl Pattern { } } +impl FromStr for Pattern { + type Err = Error; + fn from_str(s: &str) -> Result { + Self::new(s) + } +} + impl Pattern where S: StateID,