Skip to content
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

Attempt to make str -> ron::Value lossless #553

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wiiznokes
Copy link

@wiiznokes wiiznokes commented Nov 23, 2024

This PR have the same goal of #328 (i just saw it while opening this one)

This PR currently do not even compile. I'm only opening it for visibility/feedback. I think my map module have some potential though.

I came across a potential blocker (serde-rs/serde#2218). The name of a struct need to have a static lifetime somehow. I think i will try to workaround it by leaking memory for now.

I still need to figuring out the de serialization part

@juntyr
Copy link
Member

juntyr commented Nov 23, 2024

What if type (and field) names are stored using a Cow<‘static, str>? On deserialize, we just fill in a String. On serialise, we fail if the Cow is borrowed. Value then gets a convenience method to leak all owned strings (in the future we could also add a method that uses an interner so that no duplicate leaks occur).

@wiiznokes
Copy link
Author

What if type (and field) names are stored using a Cow<‘static, str>? On deserialize, we just fill in a String. On serialise, we fail if the Cow is borrowed. Value then gets a convenience method to leak all owned strings (in the future we could also add a method that uses an interner so that no duplicate leaks occur).

That seems like a nice work around

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants