fix clippy warnings

pull/54/head
Takayuki Maeda 3 years ago
parent 1cd7ddf425
commit 4a3d32cf9b

@ -6,7 +6,7 @@ use crate::{
components::tab::Tab, components::tab::Tab,
components::{ components::{
command, ConnectionsComponent, DatabasesComponent, ErrorComponent, HelpComponent, command, ConnectionsComponent, DatabasesComponent, ErrorComponent, HelpComponent,
RecordTableComponent, TabComponent, TableComponent, TableStatusComponent, RecordTableComponent, TabComponent, TableComponent,
}, },
config::Config, config::Config,
}; };

@ -49,10 +49,6 @@ impl RecordTableComponent {
self.filter.reset(); self.filter.reset();
} }
pub fn len(&self) -> usize {
self.table.rows.len()
}
pub fn filter_focused(&self) -> bool { pub fn filter_focused(&self) -> bool {
matches!(self.focus, Focus::Filter) matches!(self.focus, Focus::Filter)
} }

@ -505,7 +505,7 @@ impl DrawableComponent for TableComponent {
} else { } else {
Some(self.headers.len()) Some(self.headers.len())
}, },
self.table.as_ref().map_or(None, |t| Some(t.1.clone())), self.table.as_ref().map(|t| t.1.clone()),
) )
.draw(f, chunks[1], focused)?; .draw(f, chunks[1], focused)?;

@ -74,3 +74,18 @@ const fn calc_scroll_top(
current_top current_top
} }
} }
#[cfg(test)]
mod tests {
use super::calc_scroll_top;
#[test]
fn test_scroll_no_scroll_to_top() {
assert_eq!(calc_scroll_top(1, 10, 4, 4), 0);
}
#[test]
fn test_scroll_zero_height() {
assert_eq!(calc_scroll_top(4, 0, 4, 3), 0);
}
}

@ -159,15 +159,15 @@ impl Connection {
let user = self let user = self
.user .user
.as_ref() .as_ref()
.ok_or(anyhow::anyhow!("user is not set"))?; .ok_or_else(|| anyhow::anyhow!("user is not set"))?;
let host = self let host = self
.host .host
.as_ref() .as_ref()
.ok_or(anyhow::anyhow!("host is not set"))?; .ok_or_else(|| anyhow::anyhow!("host is not set"))?;
let port = self let port = self
.port .port
.as_ref() .as_ref()
.ok_or(anyhow::anyhow!("port is not set"))?; .ok_or_else(|| anyhow::anyhow!("port is not set"))?;
match self.database.as_ref() { match self.database.as_ref() {
Some(database) => Ok(format!( Some(database) => Ok(format!(
@ -189,15 +189,15 @@ impl Connection {
let user = self let user = self
.user .user
.as_ref() .as_ref()
.ok_or(anyhow::anyhow!("user is not set"))?; .ok_or_else(|| anyhow::anyhow!("user is not set"))?;
let host = self let host = self
.host .host
.as_ref() .as_ref()
.ok_or(anyhow::anyhow!("host is not set"))?; .ok_or_else(|| anyhow::anyhow!("host is not set"))?;
let port = self let port = self
.port .port
.as_ref() .as_ref()
.ok_or(anyhow::anyhow!("port is not set"))?; .ok_or_else(|| anyhow::anyhow!("port is not set"))?;
match self.database.as_ref() { match self.database.as_ref() {
Some(database) => Ok(format!( Some(database) => Ok(format!(

Loading…
Cancel
Save