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

feat(edit): Expose ImDocument, an Immutable Document #698

Merged
merged 17 commits into from
Mar 9, 2024
Merged

Conversation

epage
Copy link
Member

@epage epage commented Mar 8, 2024

The initial inspiration for ImDocument is that you can parse to it to lookup spans.
There is a chance for performance improvements as well because you can parse an ImDocument from a borrowed type the Deserializers are updated to take advantage of that.

Potential future improvements include

  • Allow deserializing from a &ImDocument so you don't have to clone the document to both deserialize and look up spans for richer errors
  • Allow deserializing borrowed data. This gets complicated because Value doesn't support borrowed data (and switching to owned). We'd either have to change Value or check if a string is equal to the substr the span points to and then deserialize as a borrowed value.

With this, I wonder if we should transition Document to being MutDocument, and ImDocument to being Document

Compatibility: toml_edit::de::Deserializer::new is deprecated

Compatibility: toml_edit::de::Deserializer now has a defaulted generic parameter. Its debatable on whether that is a breaking change because it can't break builds in some corner cases. I viewed the risk low enough to go forward with it.

@epage epage merged commit 8b6f77e into toml-rs:main Mar 9, 2024
12 of 13 checks passed
@epage epage deleted the im branch March 9, 2024 01:55
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.

1 participant