diff --git a/src/gopher.rs b/src/gopher.rs index 9c7dcbc..c5fbd2b 100644 --- a/src/gopher.rs +++ b/src/gopher.rs @@ -163,7 +163,8 @@ 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_all(format!("{}\r\n", selector).as_ref())?; + stream.write_all(selector.as_ref()); + stream.write_all("\r\n".as_ref()); return Ok(Stream { io: Box::new(stream), tls: true, @@ -187,7 +188,8 @@ 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_all(format!("{}\r\n", selector).as_ref())?; + stream.write_all(selector.as_ref()); + stream.write_all("\r\n".as_ref()); return Ok(Stream { io: Box::new(stream), tls: false, @@ -198,7 +200,8 @@ 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_all(format!("{}\r\n", selector).as_ref())?; + stream.write_all(selector.as_ref()); + stream.write_all("\r\n".as_ref()); Ok(Stream { io: Box::new(stream), tls: false, diff --git a/src/menu.rs b/src/menu.rs index 18bc9e6..0bbbb89 100644 --- a/src/menu.rs +++ b/src/menu.rs @@ -256,12 +256,12 @@ impl Menu { out.push_str(color!(Reset)); // clear rest of line - out.push_str(&format!("{}", clear::UntilNewline)); + out.push_str(clear::UntilNewline.as_ref()); out.push_str("\r\n"); } // clear remainder of screen - out.push_str(&format!("{}", clear::AfterCursor)); + out.push_str(clear::AfterCursor.as_ref()); out } @@ -318,7 +318,7 @@ impl Menu { if self.searching { Action::Status(self.render_input()) } else { - Action::Status(format!("{}", cursor::Hide)) + Action::Status(cursor::Hide.to_string()) } } diff --git a/src/phetchdir.rs b/src/phetchdir.rs index 6edd135..9b4d957 100644 --- a/src/phetchdir.rs +++ b/src/phetchdir.rs @@ -43,16 +43,14 @@ pub fn append(filename: &str, label: &str, url: &str) -> Result<()> { let path = dotdir.join(filename); if let Ok(mut file) = OpenOptions::new().append(true).create(true).open(path) { let u = gopher::parse_url(&url); - file.write_all( - format!( - "{}{}\t{}\t{}\t{}\r\n", - u.typ.to_char().unwrap_or('i'), - label, - u.sel, - u.host, - u.port - ) - .as_ref(), + write!( + file, + "{}{}\t{}\t{}\t{}\r\n", + u.typ.to_char().unwrap_or('i'), + label, + u.sel, + u.host, + u.port ); Ok(()) } else { @@ -75,16 +73,14 @@ pub fn prepend(filename: &str, label: &str, url: &str) -> Result<()> { let mut buf = vec![]; file.read_to_end(&mut buf); file.seek(std::io::SeekFrom::Start(0)); - file.write_all( - format!( - "{}{}\t{}\t{}\t{}\r\n", - url.typ.to_char().unwrap_or('i'), - label, - url.sel, - url.host, - url.port - ) - .as_ref(), + write!( + file, + "{}{}\t{}\t{}\t{}\r\n", + url.typ.to_char().unwrap_or('i'), + label, + url.sel, + url.host, + url.port ); file.write_all(&buf); Ok(())