Skip to content

Commit

Permalink
Add .editorconfig and .gitattributes, normalize line endings
Browse files Browse the repository at this point in the history
  • Loading branch information
gentoo90 committed Jun 1, 2018
1 parent 408761a commit 400cb47
Show file tree
Hide file tree
Showing 6 changed files with 695 additions and 681 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
root = true

[*]
charset = utf-8
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 4

[*.yml]
indent_style = space
indent_size = 2
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
86 changes: 43 additions & 43 deletions examples/installed_apps.rs
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
// Copyright 2017, Igor Shaula
// Licensed under the MIT License <LICENSE or
// http://opensource.org/licenses/MIT>. This file
// may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
extern crate winreg;
use winreg::enums::*;
use std::collections::HashMap;
use std::fmt;

#[allow(non_snake_case)]
#[derive(Debug, Serialize, Deserialize)]
struct InstalledApp {
DisplayName: Option<String>,
DisplayVersion: Option<String>,
UninstallString: Option<String>
}

macro_rules! str_from_opt {
($s:expr) => { $s.as_ref().map(|x| &**x).unwrap_or("") }
}

impl fmt::Display for InstalledApp {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}-{}",
str_from_opt!(self.DisplayName),
str_from_opt!(self.DisplayVersion))
}
}

fn main() {
let hklm = winreg::RegKey::predef(HKEY_LOCAL_MACHINE);
let uninstall_key = hklm.open_subkey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall")
.expect("key is missing");

let apps: HashMap<String, InstalledApp> = uninstall_key.decode().expect("deserialization failed");

for (_k, v) in &apps {
println!("{}", v);
}
}
// Copyright 2017, Igor Shaula
// Licensed under the MIT License <LICENSE or
// http://opensource.org/licenses/MIT>. This file
// may not be copied, modified, or distributed
// except according to those terms.
#[macro_use]
extern crate serde_derive;
extern crate winreg;
use winreg::enums::*;
use std::collections::HashMap;
use std::fmt;

#[allow(non_snake_case)]
#[derive(Debug, Serialize, Deserialize)]
struct InstalledApp {
DisplayName: Option<String>,
DisplayVersion: Option<String>,
UninstallString: Option<String>
}

macro_rules! str_from_opt {
($s:expr) => { $s.as_ref().map(|x| &**x).unwrap_or("") }
}

impl fmt::Display for InstalledApp {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}-{}",
str_from_opt!(self.DisplayName),
str_from_opt!(self.DisplayVersion))
}
}

fn main() {
let hklm = winreg::RegKey::predef(HKEY_LOCAL_MACHINE);
let uninstall_key = hklm.open_subkey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall")
.expect("key is missing");

let apps: HashMap<String, InstalledApp> = uninstall_key.decode().expect("deserialization failed");

for (_k, v) in &apps {
println!("{}", v);
}
}
Loading

0 comments on commit 400cb47

Please sign in to comment.