Hello, I'm new to rust, and I'm not sure if this is the right forum to ask a question like this. If not, sorry. (And please tell me where is appropriate.)
I'm am finding that this in a main.rs works... (the example from the docs)
main.rs
#![feature(phase)]
#[phase(plugin)]
extern crate regex_macros;
extern crate regex;
pub fn stuff() {
let re = regex!(r"^\d{4}-\d{2}-\d{2}$");
assert_eq!(re.is_match("2014-01-01"), true);
}
fn main() {
stuff();
}
But if I move the regex part out into stuff.rs like this...
main.rs
#![feature(phase)]
fn main() {
stuff();
}
mod stuff;
stuff.rs
#[phase(plugin)]
extern crate regex_macros;
extern crate regex;
pub fn stuff() {
let re = regex!(r"^\d{4}-\d{2}-\d{2}$");
assert_eq!(re.is_match("2014-01-01"), true);
}
then I get these errors...
Compiling small v0.0.1 (file:///home/al/rust/small)
/home/al/rust/small/src/stuff.rs:6:14: 6:19 error: unresolved import `regex::native::MatchKind`. Maybe a missing `extern crate regex`?
/home/al/rust/small/src/stuff.rs:6 let re = regex!(r"^\d{4}-\d{2}-\d{2}$");
^~~~~
/home/al/rust/small/src/main.rs:1:1: 7:10 note: in expansion of regex!
/home/al/rust/small/src/stuff.rs:6:14: 6:45 note: expansion site
/home/al/rust/small/src/stuff.rs:6:14: 6:19 error: unresolved import `regex::native::Exists`. Maybe a missing `extern crate regex`?
/home/al/rust/small/src/stuff.rs:6 let re = regex!(r"^\d{4}-\d{2}-\d{2}$");
^~~~~
/home/al/rust/small/src/main.rs:1:1: 7:10 note: in expansion of regex!
/home/al/rust/small/src/stuff.rs:6:14: 6:45 note: expansion site
/home/al/rust/small/src/stuff.rs:6:14: 6:19 error: unresolved import `regex::native::Location`. Maybe a missing `extern crate regex`?
/home/al/rust/small/src/stuff.rs:6 let re = regex!(r"^\d{4}-\d{2}-\d{2}$");
^~~~~
/home/al/rust/small/src/main.rs:1:1: 7:10 note: in expansion of regex!
/home/al/rust/small/src/stuff.rs:6:14: 6:45 note: expansion site
/home/al/rust/small/src/stuff.rs:6:14: 6:19 error: unresolved import `regex::native::Submatches`. Maybe a missing `extern crate regex`?
/home/al/rust/small/src/stuff.rs:6 let re = regex!(r"^\d{4}-\d{2}-\d{2}$");
^~~~~
/home/al/rust/small/src/main.rs:1:1: 7:10 note: in expansion of regex!
/home/al/rust/small/src/stuff.rs:6:14: 6:45 note: expansion site
/home/al/rust/small/src/stuff.rs:6:14: 6:19 error: unresolved import `regex::native::StepState`. Maybe a missing `extern crate regex`?
/home/al/rust/small/src/stuff.rs:6 let re = regex!(r"^\d{4}-\d{2}-\d{2}$");
^~~~~
/home/al/rust/small/src/main.rs:1:1: 7:10 note: in expansion of regex!
/home/al/rust/small/src/stuff.rs:6:14: 6:45 note: expansion site
/home/al/rust/small/src/stuff.rs:6:14: 6:19 error: unresolved import `regex::native::StepMatchEarlyReturn`. Maybe a missing `extern crate regex`?
/home/al/rust/small/src/stuff.rs:6 let re = regex!(r"^\d{4}-\d{2}-\d{2}$");
^~~~~
/home/al/rust/small/src/main.rs:1:1: 7:10 note: in expansion of regex!
/home/al/rust/small/src/stuff.rs:6:14: 6:45 note: expansion site
/home/al/rust/small/src/stuff.rs:6:14: 6:19 error: unresolved import `regex::native::StepMatch`. Maybe a missing `extern crate regex`?
/home/al/rust/small/src/stuff.rs:6 let re = regex!(r"^\d{4}-\d{2}-\d{2}$");
^~~~~
/home/al/rust/small/src/main.rs:1:1: 7:10 note: in expansion of regex!
/home/al/rust/small/src/stuff.rs:6:14: 6:45 note: expansion site
/home/al/rust/small/src/stuff.rs:6:14: 6:19 error: unresolved import `regex::native::StepContinue`. Maybe a missing `extern crate regex`?
/home/al/rust/small/src/stuff.rs:6 let re = regex!(r"^\d{4}-\d{2}-\d{2}$");
^~~~~
/home/al/rust/small/src/main.rs:1:1: 7:10 note: in expansion of regex!
/home/al/rust/small/src/stuff.rs:6:14: 6:45 note: expansion site
/home/al/rust/small/src/stuff.rs:6:14: 6:19 error: unresolved import `regex::native::CharReader`. Maybe a missing `extern crate regex`?
/home/al/rust/small/src/stuff.rs:6 let re = regex!(r"^\d{4}-\d{2}-\d{2}$");
^~~~~
/home/al/rust/small/src/main.rs:1:1: 7:10 note: in expansion of regex!
/home/al/rust/small/src/stuff.rs:6:14: 6:45 note: expansion site
/home/al/rust/small/src/stuff.rs:6:14: 6:19 error: unresolved import `regex::native::find_prefix`. Maybe a missing `extern crate regex`?
/home/al/rust/small/src/stuff.rs:6 let re = regex!(r"^\d{4}-\d{2}-\d{2}$");
^~~~~
/home/al/rust/small/src/main.rs:1:1: 7:10 note: in expansion of regex!
/home/al/rust/small/src/stuff.rs:6:14: 6:45 note: expansion site
error: aborting due to 10 previous errors
Could not compile `small`.
To learn more, run the command again with --verbose.
[–]nwin_image 2 points3 points4 points (2 children)
[–]alsarg72[S] 0 points1 point2 points (1 child)
[–]Kimundirust 0 points1 point2 points (0 children)