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)
5fn main() {
6 let editorconfig_path = "tests/test_data/.editorconfig";
7
8 // File must be provided
9 let editorconfig = EditorConfig::from_file(editorconfig_path).unwrap();
10
11 if let Some(indent_style) = editorconfig.get_property("*", "end_of_line") {
12 println!("EOL: {}", indent_style);
13 } else {
14 println!("End of line not specified.");
15 }
16}
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)
5fn main() {
6 let editorconfig_path = "tests/test_data/.editorconfig";
7
8 // File must be provided
9 let editorconfig = EditorConfig::from_file(editorconfig_path).unwrap();
10
11 if let Some(indent_style) = editorconfig.get_property("*", "end_of_line") {
12 println!("EOL: {}", indent_style);
13 } else {
14 println!("End of line not specified.");
15 }
16}
More examples
examples/from_str.rs (line 17)
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}
Trait Implementations§
Auto Trait Implementations§
impl Freeze for EditorConfig
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