GithubHelp home page GithubHelp logo

Comments (2)

xmppftw avatar xmppftw commented on August 23, 2024

Could it be because serializing a simple string without an associated key is not supported? I noticed that this also fails with the same error message:

    let foo = String::from("test");
    println!("{} - {:?}", &foo, toml::to_string(&foo));

I did not find something about string literals without keys in the TOML spec. If so, it's not a bug but rather a quality of life request to have an actually useful error message in this case saying that a key is required.

from toml.

epage avatar epage commented on August 23, 2024

Note: v0.5 and before, TOML values and documents were conflated together and this wouldn't have errrored but would have created an invalid TOML document. We've since made been more strict on the difference which also fixed some corner cases in what we can parse.

For toml, we've publicly exposed the error types. Technically, its exhaustive and we can add new variants but this is really a special case of UnsupportedType, so I'd rather not change away from that.

When we deserialize, we do so by converting it into a toml_edit::Value and then converting that into a toml_edit::Document. This allows us to reuse a lot of code but it prevents us from getting a more precise type to give to UnsupportedType.

We could hack in toml_edit::Value::type_name but I think that is misleading, telling the user a type in terms of TOML that is unsupported when the error is reporting things in terms of rust types.

I'm inclined to not act on this.

from toml.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.