We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 910aef4 + e010a8b commit 526fd07Copy full SHA for 526fd07
src/re.rs
@@ -14,6 +14,7 @@ use std::collections::hash_map::Iter;
14
use std::fmt;
15
#[cfg(feature = "pattern")]
16
use std::str::pattern::{Pattern, Searcher, SearchStep};
17
+use std::str::FromStr;
18
19
use compile::Program;
20
use parse;
@@ -158,6 +159,15 @@ impl fmt::Debug for Regex {
158
159
}
160
161
162
+impl FromStr for Regex {
163
+ type Err = parse::Error;
164
+
165
+ /// Attempts to parse a string into a regular expression
166
+ fn from_str(s: &str) -> Result<Regex, parse::Error> {
167
+ Regex::new(s)
168
+ }
169
+}
170
171
impl Regex {
172
/// Compiles a dynamic regular expression. Once compiled, it can be
173
/// used repeatedly to search, split or replace text in a string.
0 commit comments