-
Notifications
You must be signed in to change notification settings - Fork 109
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
Enforce constraints #19
Comments
I'm totally fine with this being a… let's call it "intention-preserving pretty printer" :) At the last rust.cologne meetup, we talked about a more simplistic approach to a toml reader/writer specifically for cargo-edit. One design we landed on was Having the whole toml AST consist of slices of the input string (maybe represented as rope). Adding/removing an entry would then "just" be inserting another slice at some position, or removing slice(s). I doubt this scales well to a more general purpose library, though. |
Thanks for the feedback! I think I've got an idea on how to improve API without implementing this proposal. As for duplication in Table and InlineTable, a viable approach worth investigating may be to create a common trait TableLike and implement a method on them, which will return a trait object. I'm going to close this issue. |
chore(ci): Ensure CI job always runs
Problems
This greatly complicates internal design of
toml_edit
, e.g. we have to store this order somewhere outside of the tables (document), and in order to support table insertion and deletion onTable
, we have to store a pointer to the document in it. That's why we don't allow a user to own aTable
, providing only a (mut) ref to aTable
.If we are free to reorder the tables when printing them, we can simplify the design and get rid of the no-ownership constraint. This, in turn, would allow us to have a single
Value
enum and implementserde_json
-like nice API and get rid of unsafe code!In order to preserve this layout, we have to store the whole header in the
Table
, but thenTable
assignment would be unfortunate, because header will also be mutated, while inhashmap
, storing subtable index, there still be the old key.Proposal
Unresolved: should we sort the children as well?
cc @killercup, what do you think?
The text was updated successfully, but these errors were encountered: