我正在尝试为我正在用 Rust 编写的项目编写文档。其中一个文档需要使用regex::Regex
. 这是我正在尝试编写的文档:
/// Return a list of the offsets of the tokens in `s`, as a sequence of `(start, end)`
/// tuples, by splitting the string at each successive match of `regex`.
///
/// # Examples
///
/// ```
/// use rusty_nltk::tokenize::util::regexp_span_tokenize;
/// use regex::Regex;
///
/// let s = "Good muffins cost $3.88\nin New York. Please buy me
/// two of them.\n\nThanks.";
/// let regex = regex::Regex::new(r"\s").unwrap();
/// let spans = regexp_span_tokenize(s, regex).unwrap();
/// ```
它给了我这个错误:
---- tokenize::util::regexp_span_tokenize_0 stdout ----
<anon>:4:9: 4:14 error: unresolved import `regex::Regex`. Maybe a missing `extern crate regex`? [E0432]
<anon>:4 use regex::Regex;
^~~~~
error: aborting due to previous error
但是当我添加时extern crate regex;
,我得到了这个错误:
---- tokenize::util::regexp_span_tokenize_0 stdout ----
<anon>:3:9: 3:19 error: unresolved import `rusty_nltk::tokenize::util::regexp_span_tokenize`. Maybe a missing `extern crate rusty_nltk`? [E0432]
<anon>:3 use rusty_nltk::tokenize::util::regexp_span_tokenize;
^~~~~~~~~~
<anon>:4:9: 4:14 error: unresolved import `regex::Regex`. Did you mean `self::regex`? [E0432]
<anon>:4 use regex::Regex;
^~~~~
error: aborting due to 2 previous errors
相关文件的一些相关部分是:
src/lib.rs:
extern crate regex;
pub mod tokenize;
src/tokenize/mod.rs:
extern crate regex;
pub mod util;
(顶部)src/tokenize/util.rs:
extern crate regex;
use regex::Regex;
我的项目布局做错了什么?