I'm trying to run rust code from the postgres_types
documentation.
The example code can be found here: postgres_types
my rust environment:
cargo --version cargo 1.40.0-nightly (5da4b4d47 2019-10-28)
rustc --version rustc 1.40.0-nightly (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"
When I try and run with cargo run
I get:
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)]
| ^^^^^^^
What am I doing wrong here? Clearly I'm missing something basic. Have I not imported the macro correctly?