File tree Expand file tree Collapse file tree 2 files changed +10
-13
lines changed
Expand file tree Collapse file tree 2 files changed +10
-13
lines changed Original file line number Diff line number Diff line change @@ -1263,8 +1263,8 @@ pub fn run_with_args(args: &Cli, _allupdate: bool) -> i32 {
12631263 }
12641264
12651265 // Must be run before any application code to set the config
1266- if args . pd_addrs . is_some ( ) && args. pd_ports . is_some ( ) {
1267- let platform = Platform :: GenericFramework ( args . pd_addrs . unwrap ( ) , args . pd_ports . unwrap ( ) ) ;
1266+ if let ( Some ( pd_addrs) , Some ( pd_ports ) ) = ( args. pd_addrs , args . pd_ports ) {
1267+ let platform = Platform :: GenericFramework ( pd_addrs, pd_ports) ;
12681268 Config :: set ( platform) ;
12691269 }
12701270
Original file line number Diff line number Diff line change @@ -616,17 +616,14 @@ fn print_battery_information(power_info: &PowerInfo) {
616616pub fn check_update_ready ( power_info : & PowerInfo ) -> bool {
617617 // Checking if battery/AC conditions are enough for FW update
618618 // Either standalone mode or AC+20% charge
619- if power_info. battery . is_none ( )
620- || ( power_info. ac_present && power_info. battery . as_ref ( ) . unwrap ( ) . charge_percentage > 20 )
621- {
622- true
623- } else {
624- println ! ( "Please plug in AC. If the battery is connected, charge it to at least 20% before proceeding." ) ;
625- println ! (
626- "Current charge is: {}%" ,
627- power_info. battery. as_ref( ) . unwrap( ) . charge_percentage
628- ) ;
629- false
619+ match & power_info. battery {
620+ None => true ,
621+ Some ( battery) if power_info. ac_present && battery. charge_percentage > 20 => true ,
622+ Some ( battery) => {
623+ println ! ( "Please plug in AC. If the battery is connected, charge it to at least 20% before proceeding." ) ;
624+ println ! ( "Current charge is: {}%" , battery. charge_percentage) ;
625+ false
626+ }
630627 }
631628}
632629
You can’t perform that action at this time.
0 commit comments