toml icon indicating copy to clipboard operation
toml copied to clipboard

What should I do if I just want to parse the value

Open monadbobo opened this issue 2 years ago • 1 comments

For example the following code I just want to parse the hashmap:

let v:HashMap<String, String> = toml::from_str(r#"{biz= "b1", type= "t1"}")

monadbobo avatar Oct 03 '22 11:10 monadbobo

Whats the use case for parsing a specific data type from within the toml spec?

Supporting something like this would require a specific way to opt-in as it would be an invalid toml document and compliance requires we error on a case like this.

toml_edit uses more specific types and we could implement FromStr for them as a way to opt-in.

epage avatar Oct 03 '22 14:10 epage

main supports the following

  • string.parse::<toml_edit::Value>()
  • string.parse::<toml_edit::de::ValueDeserializer>()
  • toml::ValueDeserializer::new(string)`

As this seems to now be covered, I'm closing this out. If there is something I missed, let me know and we can re-open.

epage avatar Jan 18 '23 17:01 epage