-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
toml 0.6.0 no longer allows deserializing a struct with an explicit lifetime #490
Comments
This was an intentional change as by using |
Got it. Is there a documentation change that can be made to make that explicit? I looked through the changelog but nothing stood out as the cause for this which is why I ended up raising this issue. |
The changelog was updated. |
So why does toml_edit convert everything to String? |
In theory, we could add an internal In theory, we could also parse into a As an alternative to |
It seems quite surprising to me to just throw away the ability to zero-copy/low-allocation deserialization when that is one of the main benefits usually offered by serde integrations. Offering a |
Do you have a use case where the benefits of zero-copy / low allocation deserialization is important? Assuming its performance driven, what is the actual performance before/after this and what is your performance target and why is that performance target set? |
I don't currently have such a use case. My usage of toml that prompted these questions was for Askama's configuration file. |
For what is worth, I'd like to point out that |
The difference between |
I just had to revert one of my projects to 0.5.11 to be able to deserialize without allocations. |
What is your use case that you are avoiding allocations? |
@Yuri6037 please note that due to what was stated on #505 and #490 (comment) no-allocation deserialization was not possible with the Edit: I reviewed the old deserialization code for a bit and indeed it seems it had some logic for handling borrowed and owned strings separately, so it turns out that in previous versions zero-copy string deserialization may indeed have been possible. But with the current design it's indeed no longer possible, even if the |
I'm trying to improve performance in one of my app which already does far too many allocations. |
I'm not using a Cow, I use from_str with a &str and all models use &'a based fields. |
Could you expand on your use case where TOML string allocations are a performance concern in your allocation? For context on my perspective, I deal with Cargo's performance which for certain projects can load hundreds of TOML files. Even in that situation, TOML is a fraction of a fraction of where the end-user is going and only that is noticeable in no-op runs. The only reason I'm caring about no-op run performance is for shell completions calling into cargo. Like with Cargo, TOML is mostly dealt with in application initialization and most other applications load a fraction of the TOML files.
Unless you are intentionally restricting your string inputs, this will reject perfectly valid TOML files because any escaped values will need an allocation. |
I've raised #489 as a minimal repro within the existing test suite
The text was updated successfully, but these errors were encountered: