@@ -9,7 +9,7 @@ use std::io::{BufRead, BufReader};
99pub fn get_errno_with_message ( return_code : i32 ) -> String {
1010 let e = errno ( ) ;
1111 let code = e. 0 ;
12- format ! ( "return code = {}, errno = {}, message = '{}'" , return_code , code , e )
12+ format ! ( "return code = {return_code }, errno = {code }, message = '{e }'" )
1313}
1414
1515/// Helper function that depending on the `ret` value:
@@ -25,7 +25,7 @@ pub fn check_errno(ret: i32, buf: &mut Vec<u8>) -> Result<String, String> {
2525
2626 match String :: from_utf8 ( buf. to_vec ( ) ) {
2727 Ok ( return_value) => Ok ( return_value) ,
28- Err ( e) => Err ( format ! ( "Invalid UTF-8 sequence: {}" , e ) )
28+ Err ( e) => Err ( format ! ( "Invalid UTF-8 sequence: {e}" ) )
2929 }
3030 }
3131}
@@ -35,10 +35,10 @@ pub fn check_errno(ret: i32, buf: &mut Vec<u8>) -> Result<String, String> {
3535/// This will be more useful when implementing more linux functions
3636pub fn procfile_field ( filename : & str , field_name : & str ) -> Result < String , String > {
3737 const SEPARATOR : & str = ":" ;
38- let line_header = format ! ( "{}{}" , field_name , SEPARATOR ) ;
38+ let line_header = format ! ( "{field_name}{SEPARATOR}" ) ;
3939
4040 // Open the file in read-only mode (ignoring errors).
41- let file = File :: open ( filename) . map_err ( |_| format ! ( "Could not open /proc file '{}'" , filename ) ) ?;
41+ let file = File :: open ( filename) . map_err ( |_| format ! ( "Could not open /proc file '{filename }'" ) ) ?;
4242 let reader = BufReader :: new ( file) ;
4343
4444 // Read the file line by line using the lines() iterator from std::io::BufRead.
@@ -50,7 +50,7 @@ pub fn procfile_field(filename: &str, field_name: &str) -> Result<String, String
5050 }
5151 }
5252
53- Err ( format ! ( "Could not find the field named '{}' in the /proc FS file name '{}'" , field_name , filename ) )
53+ Err ( format ! ( "Could not find the field named '{field_name }' in the /proc FS file name '{filename }'" ) )
5454}
5555
5656#[ cfg( target_os = "linux" ) ]
@@ -59,14 +59,14 @@ pub fn procfile_field(filename: &str, field_name: &str) -> Result<String, String
5959pub fn parse_memory_string ( line : & str ) -> Result < u64 , String > {
6060 let parts: Vec < & str > = line. trim ( ) . split ( ' ' ) . collect ( ) ;
6161 if parts. is_empty ( ) {
62- return Err ( format ! ( "Could not parse Memory String: {}" , line ) )
62+ return Err ( format ! ( "Could not parse Memory String: {line}" ) )
6363 }
6464 let multiplier: u64 = if parts. len ( ) == 2 {
6565 match parts[ 1 ] {
6666 "MB" => 1024 * 1024 ,
6767 "kB" => 1024 ,
6868 "B" => 1 ,
69- _ => return Err ( format ! ( "Could not parse units of Memory String: {}" , line ) )
69+ _ => return Err ( format ! ( "Could not parse units of Memory String: {line}" ) )
7070 }
7171 } else {
7272 1
0 commit comments