从 toml 文件读取的字符串值包含额外的引号:
# Toml file
string_key = "fdsafdsafdsfds"
代码:
let cfg_file_content = get_config_file_content();
let cfg_data: Value = toml::from_str(&cfg_file_content).expect("failed to parse toml");
cfg_data.as_table().unwrap();
//1
let val1 = cfg_data.get("string_key").unwrap();
// ====> \""fdsafdsafdsfds\""
// or String("fdsafdsafdsfds")
//2
let val = format!("value is: {}", val1);
println!("{:?}", val);
// ====> "value is: \"fdsafdsafdsfds\""
如何删除这些额外的引号?
箱:
toml = "0.4.5"