Function dotproperties::parse_from_file [] [src]

pub fn parse_from_file<P: AsRef<Path>>(
    path: P
) -> Result<Vec<(String, String)>, Error>

Parse the file and return a vec of key/value pairs. The order of the elements in the parsed content is preserved.

Keys are not guaranteed to be unique.

Examples

let parsed = dotproperties::parse_from_file("config.properties").unwrap();

It is often more convenient to work with a map, instead of a vec of pairs. The conversion can be done using the tools from std.

use std::collections::HashMap;

let parsed = dotproperties::parse_from_file("config.properties").unwrap();
let mapped : HashMap<_,_> = parsed.into_iter().collect();

Note that if you use collect to create a map from a vec containing duplicate keys, only the value of the last one is retained.

Failures

There is no fine-grained error reporting, yet. If the function encounters a parse error or an IO error, then an empty struct Error is returned.