I am still quite a rookie on Rust.
I try to use NaiveDateTime in some of my diesel models.
Therefore I try to import chrono as an extern crate like this:
src/db/models.rs
extern crate diesel;
extern crate chrono;
use diesel::{sql_types};
use chrono;
// model implementations follow below ...
However I am getting a rust error saying:
can't find crate for `chrono`: can't find crate
chrono is declared as a diesel feature. My Cargo.toml looks like this:
[package]
name = "backend"
version = "0.1.0"
authors = ["My Name <[email protected]>"]
edition = "2018"
[dependencies]
actix-web="3"
diesel= { version = "1.4.5", features = ["mysql", "chrono"] }
dotenv= { version = "0.15.0" }
[[bin]]
name = "main"
path = "src/main.rs"
What am I doing wrong here?
You need to install
chrono
itself.Adding a
chrono
feature todiesel
only makesdiesel
compile with a dependency onchrono
and glue code to integrate it. However, to usechrono
in your own crate, you still have to declare it inCargo.toml
.