Skip to main content

parse

Function parse 

Source
pub fn parse(src: &str) -> Result<Value, IniError>
Expand description

Parse an INI source string with the shared default parser.

The engine is built once, on first use, and reused after that. Both other runtimes do the same (sync.Once in go/ini.go, a lazily assigned module variable in the TypeScript tests), and reuse is safe here for the same reason it is there: Tabnas::parse takes &self and builds a fresh parse context per call, and Tabnas is Send + Sync, so concurrent callers share one installed grammar instead of each rebuilding it.

let value = tabnas_ini::parse("a = 1\n[s]\nb = 2")?;
assert_eq!(value.to_string(), r#"{"a":"1","s":{"b":"2"}}"#);