-
-
Notifications
You must be signed in to change notification settings - Fork 160
Can't use with borrowed values in a struct #94
Comments
|
Ah ok thanks! I didn't look at the implementation differences between the two. Perhaps once my workload lessens I can see what it would take to put this together. |
FWIW, I'm running into this as well. I've got a bit of a specialized port of Rails/Ruby's I18n YAML stuff for translating some things for a private crate. Since the data I'm after is really just a static lookup table (that's deserialized from YAML), I was hoping to generate a static struct containing the translations. Just thought I'd leave my use case here in case it helps give some clout to the ticket. |
I posted a request for implementation for a new backend: dtolnay/request-for-implementation#9. |
This does a lot of string copying. Turns out serde_yaml can't handle deserialization of borrowed vals[1] so I implemented with heap-allocated strings for now. Need to do error handling on file missing, unit not found, failure to read file and failure to deserialize file. [1] dtolnay/serde-yaml#94
As of 0.9, serde-yaml uses a new YAML backend, which supports this. |
Myself and @savish are working on porting
clap
to useserde
for all the serialization and deserialization in clap v3. Currently, YAML is the most popular format to deserialize from forclap
(because it's the only supported way in v2 😜 ). So we started with a YAML test.When trying to derive
Deserialize
forclap::App
we run into the error about the'de
lifetime:However, if we do the exact same test with
serde_json
(using a JSON document of course) everything works. So no changes to theclap::App
struct, just usingserde_json
instead ofserde_yaml
it all works.Version of
serde_yaml
0.7.5
May be related to #85?
The text was updated successfully, but these errors were encountered: