@@ -15,12 +15,7 @@ pub struct ConfigHandle {
1515
1616impl ConfigHandle {
1717 pub fn find_alias < ' a > ( & ' a self , name : & str ) -> Option < & ' a crate :: BootAlias > {
18- for alias in & self . config . aliases {
19- if alias. name == name {
20- return Some ( alias) ;
21- }
22- }
23- None
18+ self . config . aliases . iter ( ) . find ( |& alias| alias. name == name) . map ( |v| v as _ )
2419 }
2520
2621 pub fn aliases ( & self ) -> & Vec < crate :: BootAlias > {
@@ -104,7 +99,7 @@ fn load_config(path: impl AsRef<Path>) -> miette::Result<Config> {
10499 Err ( _) => {
105100 let default_config = Config :: default ( ) ;
106101 save_config ( & path, & default_config) ?;
107- return Ok ( default_config) ;
102+ Ok ( default_config)
108103 }
109104 }
110105}
@@ -128,7 +123,7 @@ pub fn determine_config_path(path: Option<PathBuf>) -> miette::Result<PathBuf> {
128123}
129124
130125fn default_config_path ( ) -> PathBuf {
131- // HEURISTIC: BOOTIT_CONFIG_PATH, $HOME/.config /bootit.yaml,
126+ // HEURISTIC: BOOTIT_CONFIG_PATH, /etc /bootit.yaml,
132127 // C:\ProgramData\bootit\config.yaml
133128
134129 if let Ok ( env_path) = std:: env:: var ( "BOOTIT_CONFIG_PATH" ) {
@@ -138,10 +133,8 @@ fn default_config_path() -> PathBuf {
138133 if cfg ! ( target_os = "windows" ) {
139134 let program_data =
140135 std:: env:: var ( "PROGRAMDATA" ) . unwrap_or_else ( |_| "C:\\ ProgramData" . to_string ( ) ) ;
141- return PathBuf :: from ( format ! ( "{}\\ bootit\\ config.yaml" , program_data) ) ;
136+ PathBuf :: from ( format ! ( "{}\\ bootit\\ config.yaml" , program_data) )
142137 } else {
143- // using HOME, to support SETUID
144- let home_env = std:: env:: var ( "HOME" ) . unwrap_or_else ( |_| "." . to_string ( ) ) ;
145- return PathBuf :: from ( format ! ( "{}/.config/bootit.yaml" , home_env) ) ;
138+ PathBuf :: from ( "/etc/bootit.yaml" . to_string ( ) )
146139 }
147140}
0 commit comments