Closed
Description
I took the first example from the README, and tried to run it with the current stable compiler:
$ rustc --version
rustc 1.17.0 (56124baa9 2017-04-24)
These are my files:
# Cargo.toml
[package]
name = "regex-example"
version = "0.1.0"
authors = ["Alex Chan <[email protected]>"]
[dependencies]
regex = "0.2"
// src/main.rs
extern crate regex;
use regex::Regex;
fn main() {
let re = Regex::new(r"(?x)
(?P<year>\d{4}) # the year
-
(?P<month>\d{2}) # the month
-
(?P<day>\d{2}) # the day
").unwrap();
let caps = re.captures("2010-03-14").unwrap();
assert_eq!("2010", caps["year"]);
assert_eq!("03", caps["month"]);
assert_eq!("14", caps["day"]);
If I take these two files in a new project and run cargo run
, I get an error:
$ cargo run
Updating registry `https://github.com/rust-lang/crates.io-index`
Downloading aho-corasick v0.6.3
Downloading libc v0.2.22
Compiling regex-syntax v0.4.0
Compiling void v1.0.2
Compiling libc v0.2.22
Compiling utf8-ranges v1.0.0
Compiling unreachable v0.1.1
Compiling thread-id v3.0.0
Compiling memchr v1.0.1
Compiling thread_local v0.3.3
Compiling aho-corasick v0.6.3
Compiling regex v0.2.1
Compiling regex-example v0.1.0 (file:///private/var/folders/0d/p_z4b6f90g1gc8h9y87w0td80000gn/T/tmp.l0If1jQ6/regex-example)
error[E0277]: the trait bound `&str: std::cmp::PartialEq<str>` is not satisfied
--> src/main.rs:15:5
|
15 | assert_eq!("2010", caps["year"]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::cmp::PartialEq<str>` is not implemented for `&str`
|
= help: the following implementations were found:
<str as std::cmp::PartialEq>
<str as std::cmp::PartialEq<std::ffi::OsString>>
<str as std::cmp::PartialEq<std::ffi::OsStr>>
<str as std::cmp::PartialEq<std::string::String>>
and 3 others
= note: this error originates in a macro outside of the current crate
error[E0277]: the trait bound `&str: std::cmp::PartialEq<str>` is not satisfied
--> src/main.rs:16:5
|
16 | assert_eq!("03", caps["month"]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::cmp::PartialEq<str>` is not implemented for `&str`
|
= help: the following implementations were found:
<str as std::cmp::PartialEq>
<str as std::cmp::PartialEq<std::ffi::OsString>>
<str as std::cmp::PartialEq<std::ffi::OsStr>>
<str as std::cmp::PartialEq<std::string::String>>
and 3 others
= note: this error originates in a macro outside of the current crate
error[E0277]: the trait bound `&str: std::cmp::PartialEq<str>` is not satisfied
--> src/main.rs:17:5
|
17 | assert_eq!("14", caps["day"]);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::cmp::PartialEq<str>` is not implemented for `&str`
|
= help: the following implementations were found:
<str as std::cmp::PartialEq>
<str as std::cmp::PartialEq<std::ffi::OsString>>
<str as std::cmp::PartialEq<std::ffi::OsStr>>
<str as std::cmp::PartialEq<std::string::String>>
and 3 others
= note: this error originates in a macro outside of the current crate
error: aborting due to 3 previous errors
error: Could not compile `regex-example`.
To learn more, run the command again with --verbose.
Metadata
Metadata
Assignees
Labels
No labels