Skip to content
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

Examples need improvement - missing basic example that reads from a file, not a string variable. #685

Open
kyleproj opened this issue Feb 13, 2024 · 2 comments

Comments

@kyleproj
Copy link

kyleproj commented Feb 13, 2024

It seems a bit silly to make a library about reading toml files but the examples provided "decode.rs" and "enum_external.rs" both read from a string variable embedded in the code, and not an actual example.toml file.

Please provide an example "basic.rs", this should be the capstone example that everyone goes to when trying to figure out how to use your library.

Here's what it should do:

  1. Read from an actual toml file "assets/example.toml" (rather than an embedded string)
  2. Read in each variable type, int, string, bool, array
  3. print the result of each value.

Thanks

@epage
Copy link
Member

epage commented Feb 13, 2024

Can you help me understand why you feel that is needed. From my perspective, those are std and serde concerns. toml has nothinc special to show in either case.

@tsprlng
Copy link

tsprlng commented Dec 17, 2024

For what it's worth, as a random passer-by I would kind of second at least request (1), maybe.

I often use from_reader in serde_json and serde_yaml (perhaps sometimes wrongly, but it's become kind of "the norm" anyway).

Since the API docs don't make it explicitly clear that this is intentionally missing from toml for a reason (i.e. the supporting parser also supports edits(?)), it caused me enough confusion/curiosity that I came here to dig through issues. If the main Config/Keys example would illustrate that reading into a string is always necessary (and explain why), this could potentially be helpful to other first-time TOML users who are otherwise familiar with typical serde usage. Maybe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants