Info
This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: Serialize is not satisfied is not implemented
error[E0277]: the trait bound `DateTime<Utc>: Serialize` is not satisfied
--> src\main.rs:10:11
|
10 | #[derive( Serialize, Deserialize , Debug )]
| ^^^^^^^^^ the trait `Serialize` is not implemented for `DateTime<Utc>`
11 | struct DateStringPair {
12 | date: DateTime<Utc>,
| ---- required by a bound introduced by this call
|
= note: for local .....
|
1864 | fn serialize_field<T>(&mut self, key: &'static str, value: &T) -> Result<(), Self::Error>
| --------------- required by a bound in this associated function
1865 | where
1866 | T: ?Sized + Serialize;
| ^^^^^^^^^ required by this bound in `SerializeStruct::serialize_field`
= note: this error originates in the derive macro `Serialize` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: the trait bound `DateTime<Utc>: Deserialize<'_>` is not satisfied
--> src\main.rs:12:11
|
12 | date: DateTime<Utc>,
| ^^^^^^^^^^^^^ the trait `Deserialize<'_>` is not implemented for `DateTime<Utc>`
|
= note: for local typ....
// edition = "2024"
// [dependencies]
// chrono = "0.4.40"
// serde = { version = "1.0.219", features = ["derive"] }
// serde_json = "1.0.140"
use chrono::{DateTime, Utc};
use serde::{Serialize, Deserialize};
#[derive( Serialize, Deserialize , Debug )]
struct DateStringPair {
date: DateTime<Utc>,
string: String,
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
Ok(())
}
Errors:
Compiling playground v0.0.1 (/playground)
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.74s
Running `target/debug/playground`
2 posts - 1 participant
🏷️ rust_feed