如何使正则表达式宏工作?

How to make regex macros work?

我关注了this tutorial。但是,尝试编译示例:

#![feature(plugin)]
#[plugin] #[no_link]
extern crate regex_macros;
extern crate regex;

fn main() {
    let re = regex!(r"^\d{4}-\d{2}-\d{2}$");
    assert_eq!(re.is_match("2014-01-01"), true);
}

失败并出现以下错误:

src/main.rs:3:1: 3:27 error: can't find crate for `regex_macros`
src/main.rs:3 extern crate regex_macros;
              ^~~~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error
Could not compile `upm`.

我加了

[dependencies]
regex = "0.1.8"

给我的 Cargo.toml.

该文档似乎已被弃用。

我之前更新过 Rust:

$ rustc --version
rustc 1.0.0-nightly (74b874071 2015-02-08 00:24:03 +0000)

我现在必须遵循哪些步骤?

宏分发为 their own crate。您需要将它们添加为依赖项,在 Cargo.toml:

上的 regex 板条箱旁边
[dependencies]
regex = "0.1.8"
regex_macros = "0.1.8"

也许您可以向适当的项目提供拉取请求以加强文档!