Clippy ok

This commit is contained in:
ChristianVisintin
2020-12-15 16:31:21 +01:00
parent b865fed7e9
commit ff4f35e5f5
3 changed files with 61 additions and 73 deletions

View File

@@ -250,7 +250,7 @@ impl AuthActivity {
}; };
Ok(Bookmark { Ok(Bookmark {
address: self.address.clone(), address: self.address.clone(),
port: port, port,
protocol: match self.protocol { protocol: match self.protocol {
FileTransferProtocol::Ftp(secure) => match secure { FileTransferProtocol::Ftp(secure) => match secure {
true => String::from("FTPS"), true => String::from("FTPS"),
@@ -267,8 +267,7 @@ impl AuthActivity {
/// ///
/// Write bookmarks to file /// Write bookmarks to file
fn write_bookmarks(&mut self) { fn write_bookmarks(&mut self) {
if self.bookmarks.is_some() { if self.bookmarks.is_some() && self.context.is_some() {
if self.context.is_some() {
// Open file for write // Open file for write
if let Some(bookmarks_file) = self.init_bookmarks() { if let Some(bookmarks_file) = self.init_bookmarks() {
match self match self
@@ -307,7 +306,6 @@ impl AuthActivity {
} }
} }
} }
}
/// ### init_bookmarks /// ### init_bookmarks
/// ///
@@ -348,8 +346,8 @@ impl AuthActivity {
// Append bookmarks.toml // Append bookmarks.toml
p.push("bookmarks.toml"); p.push("bookmarks.toml");
// If bookmarks.toml doesn't exist, initializae it // If bookmarks.toml doesn't exist, initializae it
if self.context.is_some() { if self.context.is_some()
if !self && !self
.context .context
.as_ref() .as_ref()
.unwrap() .unwrap()
@@ -368,8 +366,7 @@ impl AuthActivity {
Ok(writer) => { Ok(writer) => {
let serializer: BookmarkSerializer = BookmarkSerializer {}; let serializer: BookmarkSerializer = BookmarkSerializer {};
// Serialize and write // Serialize and write
if let Err(err) = serializer.serialize(Box::new(writer), &default_hosts) if let Err(err) = serializer.serialize(Box::new(writer), &default_hosts) {
{
self.input_mode = InputMode::Popup(PopupType::Alert( self.input_mode = InputMode::Popup(PopupType::Alert(
Color::Yellow, Color::Yellow,
format!( format!(
@@ -394,7 +391,6 @@ impl AuthActivity {
} }
} }
} }
}
// return path // return path
Some(p) Some(p)
} else { } else {

View File

@@ -234,13 +234,11 @@ impl AuthActivity {
// Move bookmarks index up // Move bookmarks index up
if self.bookmarks_idx > 0 { if self.bookmarks_idx > 0 {
self.bookmarks_idx -= 1; self.bookmarks_idx -= 1;
} else { } else if let Some(hosts) = &self.bookmarks {
if let Some(hosts) = &self.bookmarks {
// Put to last index (wrap) // Put to last index (wrap)
self.bookmarks_idx = hosts.bookmarks.len() - 1; self.bookmarks_idx = hosts.bookmarks.len() - 1;
} }
} }
}
KeyCode::Down => { KeyCode::Down => {
if let Some(hosts) = &self.bookmarks { if let Some(hosts) = &self.bookmarks {
let size: usize = hosts.bookmarks.len(); let size: usize = hosts.bookmarks.len();
@@ -317,13 +315,11 @@ impl AuthActivity {
// Move bookmarks index up // Move bookmarks index up
if self.recents_idx > 0 { if self.recents_idx > 0 {
self.recents_idx -= 1; self.recents_idx -= 1;
} else { } else if let Some(hosts) = &self.bookmarks {
if let Some(hosts) = &self.bookmarks {
// Put to last index (wrap) // Put to last index (wrap)
self.recents_idx = hosts.recents.len() - 1; self.recents_idx = hosts.recents.len() - 1;
} }
} }
}
KeyCode::Down => { KeyCode::Down => {
if let Some(hosts) = &self.bookmarks { if let Some(hosts) = &self.bookmarks {
let size: usize = hosts.recents.len(); let size: usize = hosts.recents.len();

View File

@@ -273,9 +273,7 @@ impl AuthActivity {
/// ///
/// Draw local explorer list /// Draw local explorer list
pub(super) fn draw_bookmarks_tab(&self) -> Option<List> { pub(super) fn draw_bookmarks_tab(&self) -> Option<List> {
if self.bookmarks.is_none() { self.bookmarks.as_ref()?;
return None;
}
let hosts: Vec<ListItem> = self let hosts: Vec<ListItem> = self
.bookmarks .bookmarks
.as_ref() .as_ref()
@@ -318,9 +316,7 @@ impl AuthActivity {
/// ///
/// Draw local explorer list /// Draw local explorer list
pub(super) fn draw_recents_tab(&self) -> Option<List> { pub(super) fn draw_recents_tab(&self) -> Option<List> {
if self.bookmarks.is_none() { self.bookmarks.as_ref()?;
return None;
}
let hosts: Vec<ListItem> = self let hosts: Vec<ListItem> = self
.bookmarks .bookmarks
.as_ref() .as_ref()