Skip to main content

to_string

Function to_string 

Source
pub fn to_string<T: SmlSerialize + ?Sized>(value: &T) -> String
Expand description

序列化为 SML 文本 —— toml-rs 风格的顶层函数(等价于 SmlSerialize::to_sml)。

用法与 toml::to_string 一致(序列化不会失败,故直接返回 String):

let text = sml::to_string(&cfg);
assert_eq!(text, "host: web.example\nport: 8080\n");