Skip to content

Commit

Permalink
Fix clippy warnings (#383)
Browse files Browse the repository at this point in the history
  • Loading branch information
e00E authored Mar 2, 2022
1 parent 5bcba53 commit 6036354
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 25 deletions.
2 changes: 1 addition & 1 deletion crates/libtiny_client/examples/echo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fn main() {
pass: None,
realname: "tiny echo bot".to_owned(),
nicks: vec![nick],
auto_join: chans.to_owned(),
auto_join: chans,
nickserv_ident: None,
sasl_auth: None,
};
Expand Down
17 changes: 6 additions & 11 deletions crates/libtiny_tui/examples/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,12 @@ fn main() {
let nicks = ["short", "some_long_nick_name____"];
let mut nick_idx = 1;
let mut rcv_abort_fused = ReceiverStream::new(rcv_abort).fuse();
loop {
match timeout(std::time::Duration::from_secs(3), rcv_abort_fused.next()).await {
Err(_) => {
tui_clone.set_nick(SERV, nicks[nick_idx]);
tui_clone.draw();
nick_idx = (nick_idx + 1) % nicks.len();
}
Ok(_) => {
break;
}
}
while (timeout(std::time::Duration::from_secs(3), rcv_abort_fused.next()).await)
.is_err()
{
tui_clone.set_nick(SERV, nicks[nick_idx]);
tui_clone.draw();
nick_idx = (nick_idx + 1) % nicks.len();
}
});

Expand Down
2 changes: 1 addition & 1 deletion crates/libtiny_tui/examples/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fn main() {

async fn ui_task(ui: TUI, rcv_ev: mpsc::Receiver<Event>) {
let mut rcv_ev = ReceiverStream::new(rcv_ev);
while let Some(_) = rcv_ev.next().await {
while (rcv_ev.next().await).is_some() {
ui.draw();
}
}
2 changes: 1 addition & 1 deletion crates/libtiny_tui/src/input_area/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ mod tests {
let mut input_area = InputArea::new(40, 50);
// a string that will be more than one line - 41 characters
let multiline_string_no_spaces = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
input_area.set(&multiline_string_no_spaces);
input_area.set(multiline_string_no_spaces);
assert_eq!(input_area.get_height(input_area.width), 2);
}
}
2 changes: 1 addition & 1 deletion crates/libtiny_tui/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ fn small_screen_2() {

let target = MsgTarget::Chan { serv, chan };
let ts = time::at_utc(time::Timespec::new(0, 0));
tui.set_topic("Blah blah blah-", ts.clone(), serv, chan);
tui.set_topic("Blah blah blah-", ts, serv, chan);

tui.draw();

Expand Down
2 changes: 1 addition & 1 deletion crates/libtiny_tui/src/tui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ impl TUI {
key: Key,
rcv_editor_ret: &mut Option<editor::ResultReceiver>,
) -> TUIRet {
let key_action = self.key_map.get(&key).or_else(|| match key {
let key_action = self.key_map.get(&key).or(match key {
Key::Char(c) => Some(KeyAction::Input(c)),
Key::AltChar(c) => Some(KeyAction::TabGoto(c)),
_ => None,
Expand Down
2 changes: 1 addition & 1 deletion crates/termbox/examples/colors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fn draw_range(tui: &mut Termbox, begin: u16, end: u16, mut row: i32, fg: bool) -
let string = format!("{:>3}", i);
let fg_ = if fg { i } else { 0 };
let bg_ = if fg { 0 } else { i };
tui.change_cell(col, row, string.chars().nth(0).unwrap(), fg_, bg_);
tui.change_cell(col, row, string.chars().next().unwrap(), fg_, bg_);
tui.change_cell(col + 2, row, string.chars().nth(2).unwrap(), fg_, bg_);
tui.change_cell(col + 1, row, string.chars().nth(1).unwrap(), fg_, bg_);
col += 4;
Expand Down
3 changes: 1 addition & 2 deletions crates/tiny/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ fn get_default_config_yaml() -> String {
#[cfg(test)]
mod tests {
use super::*;
use serde_yaml;

#[test]
fn parse_default_config() {
Expand All @@ -224,7 +223,7 @@ mod tests {
}
Ok(Config { servers, .. }) => {
assert_eq!(servers[0].join, vec!["#tiny".to_owned()]);
assert_eq!(servers[0].tls, true);
assert!(servers[0].tls);
}
}
}
Expand Down
9 changes: 3 additions & 6 deletions crates/tiny/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use libtiny_common::ChanName;
use libtiny_tui::test_utils::expect_screen;
use libtiny_tui::TUI;
use libtiny_wire::{Cmd, Msg, MsgTarget, Pfx};
use term_input;

use termbox_simple::CellBuf;

use libtiny_client as client;
Expand Down Expand Up @@ -63,11 +63,8 @@ where
// Create test TUI
let (snd_input_ev, rcv_input_ev) = mpsc::channel::<term_input::Event>(100);
let rcv_input_ev = ReceiverStream::new(rcv_input_ev);
let (tui, _rcv_tui_ev) = TUI::run_test(
DEFAULT_TUI_WIDTH,
DEFAULT_TUI_HEIGHT,
rcv_input_ev.map(|ev| Ok(ev)),
);
let (tui, _rcv_tui_ev) =
TUI::run_test(DEFAULT_TUI_WIDTH, DEFAULT_TUI_HEIGHT, rcv_input_ev.map(Ok));

let tiny_ui = UI::new(tui.clone(), None);

Expand Down

0 comments on commit 6036354

Please sign in to comment.