I wrote this simple program:
trait Command<T> {
fn execute(&self, &mut T);
}
fn main() {
let x = 0;
}
I compiled this with rustc --edition=2018 main.rs
and get the error message:
error: expected one of `:` or `@`, found `)`
--> main.rs:2:29
|
2 | fn execute(&self, &mut T);
| ^ expected one of `:` or `@` here
Compiling via rustc --edition=2015 main.rs
or rustc main.rs
doesn't cause this error, although there are some warnings.
What's the problem with this code?
The PERMA Model, or Theory, of wellbeing was formulated by psychologist Martin Seligman and published in his 2011 book Flourish 1.
The PERMA-V model can be a useful tool when creating well-being strategies. This science-based model stems from positive psychology, and is an acronym that consists of six important building blocks: Positivity, Engagement, Relationships, Meaning, Achievement, and Vitality.
Questionnaires Overview The PERMA Profiler is a general measure, developed for adults, which measures flourishing in terms of 5 domains: positive emotion, engagement, relationships, meaning, and accomplishment, following Dr. Seligman's well-being theory (see the book Flourish for more information).
Researchers, managers, consultants, and psychologists all know that resilience is the most important factor not only to mental health but to performance and success. People who are resilient to adversity, difficulty, and stress quickly rise to the top. They are today's best performers and tomorrows leaders.
Anonymous trait parameters have been removed in 2018 edition: No more anonymous trait parameters.
Add _:
before &mut T
if you want to ignore the parameter:
trait Command<T> {
fn execute(&self, _: &mut T);
}
Compiling with rustc main.rs
works, because it defaults to --edition=2015
.
Indeed, if you put your main.rs
in a new Cargo project, then remove edition = "2018"
from Cargo.toml
, and run
cargo fix --edition
then Cargo will add the missing _:
automatically. See Transitioning an existing project to a new edition.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With