File tree Expand file tree Collapse file tree 6 files changed +9
-12
lines changed Expand file tree Collapse file tree 6 files changed +9
-12
lines changed Original file line number Diff line number Diff line change @@ -105,8 +105,7 @@ pub fn connect(opts: &SshOpts) -> RemoteResult<Session> {
105105 match opts
106106 . key_storage
107107 . as_ref ( )
108- . map ( |x| x. resolve ( ssh_config. host . as_str ( ) , ssh_config. username . as_str ( ) ) )
109- . flatten ( )
108+ . and_then ( |x| x. resolve ( ssh_config. host . as_str ( ) , ssh_config. username . as_str ( ) ) )
110109 {
111110 Some ( rsa_key) => {
112111 session_auth_with_rsakey (
Original file line number Diff line number Diff line change @@ -66,15 +66,15 @@ impl Config {
6666 let mut reader = BufReader :: new ( File :: open ( p) . map_err ( |e| {
6767 RemoteError :: new_ex (
6868 RemoteErrorType :: IoError ,
69- format ! ( "Could not open configuration file: {}" , e. to_string ( ) ) ,
69+ format ! ( "Could not open configuration file: {}" , e) ,
7070 )
7171 } ) ?) ;
7272 SshConfig :: default ( )
7373 . parse ( & mut reader)
7474 . map_err ( |e| {
7575 RemoteError :: new_ex (
7676 RemoteErrorType :: IoError ,
77- format ! ( "Could not parse configuration file: {}" , e. to_string ( ) ) ,
77+ format ! ( "Could not parse configuration file: {}" , e) ,
7878 )
7979 } )
8080 . map ( |x| x. query ( host) )
Original file line number Diff line number Diff line change @@ -215,7 +215,7 @@ impl ScpFs {
215215 /// Returns from a `ls -l` command output file name token, the name of the file and the symbolic link (if there is any)
216216 fn get_name_and_link ( & self , token : & str ) -> ( String , Option < PathBuf > ) {
217217 let tokens: Vec < & str > = token. split ( " -> " ) . collect ( ) ;
218- let filename: String = String :: from ( * tokens. get ( 0 ) . unwrap ( ) ) ;
218+ let filename: String = String :: from ( * tokens. first ( ) . unwrap ( ) ) ;
219219 let symlink: Option < PathBuf > = tokens. get ( 1 ) . map ( PathBuf :: from) ;
220220 ( filename, symlink)
221221 }
Original file line number Diff line number Diff line change @@ -145,13 +145,11 @@ impl SftpFs {
145145 fn metadata_to_filestat ( metadata : Metadata ) -> FileStat {
146146 let atime = metadata
147147 . accessed
148- . map ( |x| x. duration_since ( SystemTime :: UNIX_EPOCH ) . ok ( ) )
149- . flatten ( )
148+ . and_then ( |x| x. duration_since ( SystemTime :: UNIX_EPOCH ) . ok ( ) )
150149 . map ( |x| x. as_secs ( ) ) ;
151150 let mtime = metadata
152151 . modified
153- . map ( |x| x. duration_since ( SystemTime :: UNIX_EPOCH ) . ok ( ) )
154- . flatten ( )
152+ . and_then ( |x| x. duration_since ( SystemTime :: UNIX_EPOCH ) . ok ( ) )
155153 . map ( |x| x. as_secs ( ) ) ;
156154 FileStat {
157155 size : Some ( metadata. size ) ,
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ mod test {
4343
4444 #[ test]
4545 fn should_fmt_time ( ) {
46- let system_time: SystemTime = SystemTime :: from ( SystemTime :: UNIX_EPOCH ) ;
46+ let system_time: SystemTime = SystemTime :: UNIX_EPOCH ;
4747 assert_eq ! (
4848 fmt_time_utc( system_time, "%Y-%m-%d %H:%M" ) ,
4949 String :: from( "1970-01-01 00:00" )
Original file line number Diff line number Diff line change @@ -47,11 +47,11 @@ mod test {
4747 #[ test]
4848 fn absolutize_path ( ) {
4949 assert_eq ! (
50- absolutize( & Path :: new( "/home/omar" ) , & Path :: new( "readme.txt" ) ) . as_path( ) ,
50+ absolutize( Path :: new( "/home/omar" ) , Path :: new( "readme.txt" ) ) . as_path( ) ,
5151 Path :: new( "/home/omar/readme.txt" )
5252 ) ;
5353 assert_eq ! (
54- absolutize( & Path :: new( "/home/omar" ) , & Path :: new( "/tmp/readme.txt" ) ) . as_path( ) ,
54+ absolutize( Path :: new( "/home/omar" ) , Path :: new( "/tmp/readme.txt" ) ) . as_path( ) ,
5555 Path :: new( "/tmp/readme.txt" )
5656 ) ;
5757 }
You can’t perform that action at this time.
0 commit comments