Hi.
The following two examples of Rust By Example succeeded in building on Rust 2015 Edition, but failed to build on 2018 Edition. And I did not understand how to solve it.
How do you get to succeed in building with 2018 Edition?
error: expected one of `:` or `@`, found `,`
--> src/main.rs:6:26
|
6 | fn contains(&self, &A, &B) -> bool; // Explicitly requires `A` and `B`.
| ^ expected one of `:` or `@` here
error[E0407]: method `contains` is not a member of trait `Contains`
--> src/main.rs:13:5
|
13 | / fn contains(&self, number_1: &i32, number_2: &i32) -> bool {
14 | | (&self.0 == number_1) && (&self.1 == number_2)
15 | | }
| |_____^ not a member of trait `Contains`
error[E0599]: no method named `contains` found for type `Container` in the current scope
--> src/main.rs:39:19
|
1 | struct Container(i32, i32);
| --------------------------- method `contains` not found for this
...
39 | container.contains(&number_1, &number_2));
| ^^^^^^^^
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `contains`, perhaps you need to implement it:
candidate #1: `std::ops::RangeBounds`
error: aborting due to 3 previous errors
Some errors occurred: E0407, E0599.
For more information about an error, try `rustc --explain E0407`.
error: Could not compile `rust_by_example`.
To learn more, run the command again with --verbose.