Hello again,
I'm trying to follow part of the regex documentation by implementing my regex as a static, but, I'm receiving a compile error on the string literal. Please can anybody offer any advise?
The code:
impl Camera {
fn from_vector(fields: Vec<&str>) -> Camera {
lazy_static! {
static ref RE: Regex::new("(\\d{3})").unwrap();
}
<snip...>
The error message:
expected type, found `"(\\d{3})"`
expected typerustc
main.rs(47, 39): expected type
lib.rs(168, 46): while parsing argument for this `ty` macro fragment
As I mentioned in the other thread, using r"(\d{3})" might help improve readability as well. Also I guess you’re not needing the extra group, so the parentheses could be removed, too?
Fantastic thank you, I'm still getting used to the syntax and hadn't noticed my missing type.
The regex is now clearer too, but what does the r"" do? I've not been able to find that in the docs, can you point me towards the right page, please?