make clippy happy

pull/14/head
chris west 4 years ago
parent 75ac066caa
commit f03c6e1422

@ -91,13 +91,10 @@ pub fn exists() -> bool {
/// Parses a phetch config file into a Config struct.
pub fn parse(text: &str) -> Result<Config> {
let mut linenum = 0;
let mut cfg = default();
let mut keys: HashMap<&str, bool> = HashMap::new();
for line in text.split_terminator('\n') {
linenum += 1;
for (linenum, line) in text.split_terminator('\n').enumerate() {
// skip empty lines
if line.trim().is_empty() {
continue;

@ -123,7 +123,7 @@ pub fn download_url(url: &str, tls: bool, tor: bool) -> Result<(String, usize)>
break;
}
bytes += count;
file.write(&buf[..count]);
file.write_all(&buf[..count])?;
if let Some(Ok(termion::event::Key::Ctrl('c'))) = keys.next() {
return Err(error!("Download cancelled"));
}
@ -149,7 +149,7 @@ pub fn request(host: &str, port: &str, selector: &str, tls: bool, tor: bool) ->
let stream = TcpStream::connect_timeout(&sock, TCP_TIMEOUT_DURATION)?;
stream.set_read_timeout(Some(TCP_TIMEOUT_DURATION))?;
if let Ok(mut stream) = connector.connect(host, stream) {
stream.write(format!("{}\r\n", selector).as_ref())?;
stream.write_all(format!("{}\r\n", selector).as_ref())?;
return Ok(Stream {
io: Box::new(stream),
tls: true,
@ -165,7 +165,7 @@ pub fn request(host: &str, port: &str, selector: &str, tls: bool, tor: bool) ->
#[cfg(feature = "tor")]
{
let proxy = std::env::var("TOR_PROXY")
.unwrap_or("127.0.0.1:9050".into())
.unwrap_or_else(|_| "127.0.0.1:9050".into())
.to_socket_addrs()?
.nth(0)
.unwrap();
@ -173,7 +173,7 @@ pub fn request(host: &str, port: &str, selector: &str, tls: bool, tor: bool) ->
Ok(s) => s,
Err(e) => return Err(error!("Tor error: {}", e)),
};
stream.write(format!("{}\r\n", selector).as_ref())?;
stream.write_all(format!("{}\r\n", selector).as_ref())?;
return Ok(Stream {
io: Box::new(stream),
tls: false,
@ -184,7 +184,7 @@ pub fn request(host: &str, port: &str, selector: &str, tls: bool, tor: bool) ->
// no tls or tor, try regular connection
let mut stream = TcpStream::connect_timeout(&sock, TCP_TIMEOUT_DURATION)?;
stream.set_read_timeout(Some(TCP_TIMEOUT_DURATION))?;
stream.write(format!("{}\r\n", selector).as_ref())?;
stream.write_all(format!("{}\r\n", selector).as_ref())?;
Ok(Stream {
io: Box::new(stream),
tls: false,

@ -1,4 +1,5 @@
#![allow(unused_must_use)]
#![allow(clippy::while_let_on_iterator)]
#[macro_use]
pub mod utils;

@ -130,7 +130,7 @@ fn print_plain(url: &str, tls: bool, tor: bool) -> i32 {
// TODO use parse_line()
for line in response.trim_end_matches(".\r\n").lines() {
let line = line.trim_end_matches('\r');
if let Some(desc) = line.splitn(2, "\t").nth(0) {
if let Some(desc) = line.splitn(2, '\t').nth(0) {
let desc = desc.trim();
out.push_str(&desc.chars().skip(1).collect::<String>());
out.push('\n');

@ -773,7 +773,7 @@ impl Menu {
lines.push(Line {
name,
url: parts[1]
.trim_start_matches("/")
.trim_start_matches('/')
.trim_start_matches("URL:")
.to_string(),
typ,

Loading…
Cancel
Save