-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
Hello, I am trying to do it.
You wrote:
you either need to specify the precise type you're deserializing without naming it (which is possible but not particularly practical)
How to do it(to deserialize)?
I use serde_traitobject and write this code
use serde_traitobject as st;
let one:usize = 1;
let two:usize = 2;
let plus_one = Fn!(|x: usize| x + one + two);
let s: st::Box<dyn serde_traitobject::Fn(usize) -> usize> = st::Box::new(plus_one);
let serialized = serde_json::to_string(&s).unwrap();
println!("{}",serialized);
let deserialized: st::Box<dyn serde_traitobject::Fn(usize) -> usize> = serde_json::from_str(serialized.as_str()).unwrap();
And I have error:
the trait bound `&usize: main::_IMPL_DESERIALIZE_FOR_MyStruct::_serde::Deserialize<'_>` is not satisfied
What should I do?
Can I create struct with two or more closures and serialize and deserialize it? Without Box<dyn ... Fn> just Box?
Metadata
Metadata
Assignees
Labels
No labels