Open ip1981 opened 3 months ago
Note that this was created out of #751
I propose making Repr::new_unchecked public and renamed to Repr::new (because Repr is self-contained, there are no invariants inside it, nothing to "check"),
What is "unchecked" is that the string must conform to the TOML specification. We currently allow "unchecked" content with Decor
and view that as non-ideal (#267).
As the community seems to feel that unsafe
should be reserved for language invariants, and not just library invariants, there also wouldn't be a good way to call out and audit these "unchecked" calls.
While working on a library to access TOML data via a "TOML path" like
foo[1].bar
, similar to toml-cli, we found convenient to reuse theKey
struct. At the same time, reusing the key's parser provided by the public interface was not only tricky, but didn't cover some additional feature requirements (like wildcards). Another feature is that keys can come from a TOML file parsed with thetoml_edit
. That's why reusingKey
is desired.Current public interface does not allow creating a
Key
and setting its representation (Repr
).I propose making
Repr::new_unchecked
public and renamed toRepr::new
(becauseRepr
is self-contained, there are no invariants inside it, nothing to "check"), and makingKey::with_repr_unchecked
public as well, renamed toKey::with_repr
.These changes will allow writing custom parsers producing keys like this:
Here is the patch: https://github.com/whamcloud/toml/commit/7f9d96077b2cfd5fc30377304958be081c9e7b7f