-
Notifications
You must be signed in to change notification settings - Fork 113
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
Item::as_table is a beatrap #838
Comments
The current naming is very consistent |
I see the value in consistency. I do think we should at least consider renaming them (and, therefore, renaming these types too). I think it's more important to provide an API that helps our users avoid foreseeable bugs, than to be 100% faithful with upstream terminology. |
This is a low level API dealing with concepts as they exist in the TOML grammar. |
Item::as_table
looks at first glance like the obvious method to call if you want to do a normal table value lookup. But it returnsNone
forItem::Value(Value::InlineTable(..))
.The call you should use instead for this is
as_table_like
. That's a longer name (so less obvious). There's nothing in the documentation ofas_table
to warn you about this.I was tripped up by this because the author of a crate that now uses toml_edit wrote the bug that this API induces. (I suspect from the history there that that project switched from another toml library, which presumably an
.as_table
function that gaveSome
for inline tables too.)I suggest:
.as_table
and.is_table
(inItem
){as,is}_table
->{as,is}_outline_table
(or similar bikeshed) and{as,is}_table_like
to{as,is}_table
.The text was updated successfully, but these errors were encountered: