Function editorconfig::get_config [] [src]

pub fn get_config(
    file_path: &Path
) -> Result<OrderMap<String, String>, Box<Error>>

Finds the configuration that applies to the file passed in file_path.

The file_path argument is the path to a file.

It looks for a file named .editorconfig in the file's directory and in every parent directory. A search for .editorconfig files will stop if root (/) is reached or an .editorconfig file with root=true is found.

Example

use std::path::Path;

let path = Path::new("./test_files/simple/file.txt");
let path = path.canonicalize().unwrap();
let res = editorconfig::get_config(&path).unwrap();
for (k, v) in res.iter() {
    println!("{}={}", *k, *v);
}

Errors

It returns an error:

  • when it can't parse it

  • when the file_path is malformed (check std::fs::canonicalize docs) or is a directory.