我正在尝试从postgres_types
文档中运行rust代码。
示例代码可在此处找到:postgres_types
我的防锈环境:
cargo --version 货物1.40.0每晚(5da4b4d47 2019-10-28)
rustc-版本 rustc 1.40.0-每晚(b520af6fd 2019-11-03)
main.rs
#[cfg(feature = "derive")]
use postgres_types::{ToSql,FromSql};
#[derive(Debug,ToSql,FromSql)]
enum Mood {
Sad,Ok,Happy,}
fn main() {
let mood = Mood::Sad;
println!("{:?}",mood);
}
Cargo.toml
...
[dependencies]
postgres-types = "0.1.0-alpha.1"
当我尝试使用cargo run
运行时,我得到:
error: cannot find derive macro `ToSql` in this scope
--> src\main.rs:4:17
|
4 | #[derive(Debug,FromSql)]
| ^^^^^
error: cannot find derive macro `FromSql` in this scope
--> src\main.rs:4:24
|
4 | #[derive(Debug,FromSql)]
| ^^^^^^^
我在这里做错了什么?显然我缺少基本的东西。我没有正确导入宏吗?