Skip to main content

from_str

Function from_str 

Source
pub fn from_str<T: SmlDeserialize>(text: &str) -> Result<T, String>
Expand description

解析 SML 文本并反序列化 —— toml-rs 风格的顶层函数(等价于 SmlDeserialize::from_sml)。

let back: Server = sml::from_str("host: web.example\nport: 8080\n").unwrap();
assert_eq!(back.host, "web.example");
assert_eq!(back.port, 8080);