Skip to content

Commit ed6f366

Browse files
committed
lint
1 parent b5b8c9c commit ed6f366

File tree

6 files changed

+9
-12
lines changed

6 files changed

+9
-12
lines changed

src/ssh/commons.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff 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(

src/ssh/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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))

src/ssh/scp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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
}

src/ssh/sftp.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff 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),

src/utils/fmt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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")

src/utils/path.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)