from_str/
from_str.rs

1//! Example of getting an editorconfig from a string
2
3use editor_config::parser::EditorConfig;
4
5fn main() {
6    let editorconfig_str = r#"
7        [*]
8        indent_style = tab
9        indent_size = 4
10
11        [*.js]
12        indent_style = space
13    "#;
14
15    let editorconfig: EditorConfig = editorconfig_str.parse().unwrap();
16
17    if let Some(indent_style) = editorconfig.get_property("*.js", "indent_style") {
18        println!("Indent Style: {}", indent_style);
19    } else {
20        println!("Indent style not specified.");
21    }
22}