@@ -45,7 +45,7 @@ pub fn svg_to_bitmap(svg_data: &str, width: u32, height: u32) -> Result<Vec<Vec<
4545 Ok ( bitmap)
4646}
4747
48- pub fn write_bitmap_to_file ( bitmap : & Vec < Vec < bool > > , filename : & str ) -> Result < ( ) > {
48+ pub fn write_bitmap_to_file ( bitmap : & [ Vec < bool > ] , filename : & str ) -> Result < ( ) > {
4949 let width = bitmap[ 0 ] . len ( ) ;
5050 let height = bitmap. len ( ) ;
5151 let mut img = GrayImage :: new ( width as u32 , height as u32 ) ;
@@ -63,19 +63,19 @@ pub fn write_bitmap_to_file(bitmap: &Vec<Vec<bool>>, filename: &str) -> Result<(
6363
6464pub fn option_or_env ( options : & OptionMap , key : & str , env_key : & str ) -> String {
6565 let option = options. get ( key) ;
66- if option . is_some ( ) {
67- option . unwrap ( ) . to_string ( )
66+ if let Some ( value ) = option {
67+ value . to_string ( )
6868 } else {
69- std:: env:: var ( env_key. to_string ( ) ) . unwrap ( ) . to_string ( )
69+ std:: env:: var ( env_key) . unwrap ( ) . to_string ( )
7070 }
7171}
7272
7373pub fn option_or_env_fallback ( options : & OptionMap , key : & str , env_key : & str , fallback : & str ) -> String {
7474 let option = options. get ( key) ;
75- if option . is_some ( ) {
76- option . unwrap ( ) . to_string ( )
75+ if let Some ( value ) = option {
76+ value . to_string ( )
7777 } else {
78- std:: env:: var ( env_key. to_string ( ) ) . unwrap_or ( fallback. to_string ( ) ) . to_string ( )
78+ std:: env:: var ( env_key) . unwrap_or_else ( |_| fallback. to_string ( ) )
7979 }
8080}
8181
@@ -104,7 +104,7 @@ pub fn setup_uinput() -> Result<()> {
104104 dotenv:: from_path ( os_info_path) ?;
105105 }
106106
107- let img_version = std:: env:: var ( "IMG_VERSION" . to_string ( ) ) . unwrap_or_default ( ) ;
107+ let img_version = std:: env:: var ( "IMG_VERSION" ) . unwrap_or_default ( ) ;
108108
109109 if img_version. is_empty ( ) {
110110 return Ok ( ( ) ) ;
@@ -115,7 +115,7 @@ pub fn setup_uinput() -> Result<()> {
115115 // let target_module_filename = format!("rmpp/uinput-{short_version}.ko");
116116
117117 // Use the function from embedded_assets module to get the module data
118- let uinput_module_data = get_uinput_module_data ( & short_version) . expect ( & format ! ( "Uinput module for version {} not found" , short_version) ) ;
118+ let uinput_module_data = get_uinput_module_data ( & short_version) . unwrap_or_else ( || panic ! ( "Uinput module for version {} not found" , short_version) ) ;
119119 let raw_uinput_module_data = uinput_module_data. as_slice ( ) ;
120120 let mut uinput_module_file = std:: fs:: File :: create ( "/tmp/uinput.ko" ) ?;
121121 uinput_module_file. write_all ( raw_uinput_module_data) ?;
0 commit comments