Comments (2)
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.
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)
- Structs with optional fields inside vectors of enums result in broken output HOT 1
- Deserialization error occurs when enum member contains multiple values
- Allow newlines and trailing commas in inline tables HOT 1
- how to upgrade when using the tables_last feature HOT 2
- toml_edit: cannot get and unwrap fields?.. HOT 5
- toml_edit feature request: Allow a table's `doc_position` to be discarded HOT 4
- When parsing, identify when decor is "default"
- support char as map key HOT 1
- The purpose of `serde_spanned`? HOT 3
- Make it possible to add error context HOT 6
- Emitting `serde_spanned` from other crates (formats) HOT 2
- Fail to work with typetag during serializing HOT 7
- Pre-commit is failing on spelling in one of toml-test's test fixtures HOT 1
- Array::sort_by_key doesn't work with Value::as_* methods
- Always deserialize "-nan" as `std::f64::NAN` HOT 1
- [BUG] - toml is not correctly using custom serialize impl HOT 1
- toml-edit - stack overflow in testsuite. HOT 5
- (possible) bug between 0.5 and 0.8 HOT 2
- Make Array of Tables inlined by default when using to_string_pretty HOT 5
- The bump on MSRV is preventing `toml_datetime` been use in old system HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from toml.