I’m trying to compile a lib in rust and I get the following error:
to use `async fn`, switch to Rust 2018 or later
This is my cargo.toml:
[package]
name = "name"
version = "0.1.0"
edition = "2018"
and to compile I use the following command line (documentation here):
rustc --crate-type=lib src/apis/my_file.rs
does anyone have an idea?
>Solution :
As the name implies Cargo.toml is interpreted by cargo, not rustc if you want to compile with rustc you have to add the edition flag:
rustc --edition=2018 --crate-type=lib src/apis/my_file.rs