I want to build a struct, in which an element is a function, and want to be able to display its contents as json
, so I wrote the below:
#[macro_use] extern crate serde_derive;
#[derive(Serialize, Deserialize)]
struct Function<'a> {
command: &'a str,
f: fn(),
}
But got the below error:
error[E0277]: the trait bound `fn(): _IMPL_DESERIALIZE_FOR_Message::_serde::Serialize` is not satisfied
--> src\main.rs:61:5
|
61 | f: fn(),
| ^^^^^^^ the trait `_IMPL_DESERIALIZE_FOR_Message::_serde::Serialize` is not implemented for `fn()`
|
= note: required by `_IMPL_DESERIALIZE_FOR_Message::_serde::ser::SerializeStruct::serialize_field`
error[E0277]: the trait bound `fn(): _IMPL_DESERIALIZE_FOR_Message::_serde::Deserialize<'_>` is not satisfied
--> src\main.rs:61:5
|
61 | f: fn(),
| ^^^^^^^ the trait `_IMPL_DESERIALIZE_FOR_Message::_serde::Deserialize<'_>` is not implemented for `fn()`
|
= note: required by `_IMPL_DESERIALIZE_FOR_Message::_serde::de::SeqAccess::next_element`
error[E0277]: the trait bound `fn(): _IMPL_DESERIALIZE_FOR_Message::_serde::Deserialize<'_>` is not satisfied
--> src\main.rs:61:5
|
61 | f: fn(),
| ^^^^^^^ the trait `_IMPL_DESERIALIZE_FOR_Message::_serde::Deserialize<'_>` is not implemented for `fn()`
|
= note: required by `_IMPL_DESERIALIZE_FOR_Message::_serde::de::MapAccess::next_value`