Closed AdamJSoftware closed 1 year ago
So here the issue is that when you take the diff of Script, the version
field may or not be the same type as T. Instead it will have the type <T as Diff>::Repr
, meaning whatever the type of struct the diff is. For example, if T were a HashMap or Vec, the diff of T (<T as Diff>::Repr
) would be a totally different struct like HashMapDiff
or VecDiff
. You have to make sure that the T implements Diff, and that T::Repr implements Debug and Serialize. It would look close to this:
#[derive(Diff)]
struct ScriptSource;
#[derive(Diff)]
#[diff(attr(#[derive(Debug, Serialize)]))]
struct Script<T: Diff>
where
<T as Diff>::Repr: Debug + Serialize,
{
functions: Vec<String>,
source: ScriptSource,
version: T,
}
Does that clear it up?
Yes it does!
I am trying to use diff with generics but I am encountering issues whenever I try to add Serializing and/or debug. Specifically, that
Here is an example,
How would I get around this?