Struct editor_config::parser::EditorConfig
source · pub struct EditorConfig {
pub config: HashMap<String, HashMap<String, String>>,
}Fields§
§config: HashMap<String, HashMap<String, String>>Implementations§
source§impl EditorConfig
impl EditorConfig
sourcepub fn from_file(file_path: &str) -> Result<Self, String>
pub fn from_file(file_path: &str) -> Result<Self, String>
Examples found in repository?
examples/get_property.rs (line 9)
5 6 7 8 9 10 11 12 13 14 15 16
fn main() {
let editorconfig_path = "tests/test_data/.editorconfig";
// File must be provided
let editorconfig = EditorConfig::from_file(editorconfig_path).unwrap();
if let Some(indent_style) = editorconfig.get_property("*", "end_of_line") {
println!("EOL: {}", indent_style);
} else {
println!("End of line not specified.");
}
}sourcepub fn get_property(&self, section: &str, property: &str) -> Option<&String>
pub fn get_property(&self, section: &str, property: &str) -> Option<&String>
Examples found in repository?
examples/get_property.rs (line 11)
5 6 7 8 9 10 11 12 13 14 15 16
fn main() {
let editorconfig_path = "tests/test_data/.editorconfig";
// File must be provided
let editorconfig = EditorConfig::from_file(editorconfig_path).unwrap();
if let Some(indent_style) = editorconfig.get_property("*", "end_of_line") {
println!("EOL: {}", indent_style);
} else {
println!("End of line not specified.");
}
}More examples
examples/from_str.rs (line 17)
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
fn main() {
let editorconfig_str = r#"
[*]
indent_style = tab
indent_size = 4
[*.js]
indent_style = space
"#;
let editorconfig: EditorConfig = editorconfig_str.parse().unwrap();
if let Some(indent_style) = editorconfig.get_property("*.js", "indent_style") {
println!("Indent Style: {}", indent_style);
} else {
println!("Indent style not specified.");
}
}Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for EditorConfig
impl Send for EditorConfig
impl Sync for EditorConfig
impl Unpin for EditorConfig
impl UnwindSafe for EditorConfig
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more