ฉันกำลังพยายามเรียกใช้โค้ดสนิมจากเอกสารประกอบ postgres_types
ดูโค้ดตัวอย่างได้ที่นี่: postgres_types
สภาพแวดล้อมที่เป็นสนิมของฉัน:
สินค้า --version สินค้า 1.40.0-คืน (5da4b4d47 2019-10-28)
rustc --versionrustc 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, ToSql, FromSql)]
| ^^^^^
error: cannot find derive macro `FromSql` in this scope
--> src\main.rs:4:24
|
4 | #[derive(Debug, ToSql, FromSql)]
| ^^^^^^^
ฉันทำอะไรผิดที่นี่? เห็นได้ชัดว่าฉันขาดอะไรบางอย่างพื้นฐานไป ฉันนำเข้ามาโครไม่ถูกต้องใช่ไหม