Browse Source

Fix clippy warnings

master
Garrit Franke 4 years ago
parent
commit
bea7868ebf
  1. 4
      src/gemini.rs
  2. 8
      src/main.rs

4
src/gemini.rs

@ -41,7 +41,7 @@ impl GeminiResponse {
pub fn success(body: Vec<u8>) -> Self {
GeminiResponse {
status: [b'2', b'0'],
meta: "text/gemini; charset=utf-8".as_bytes().to_vec(),
meta: b"text/gemini; charset=utf-8".to_vec(),
body: Some(body),
}
}
@ -66,7 +66,7 @@ impl GeminiResponse {
// <Meta>
buf.extend(&self.meta);
buf.extend("\r\n".as_bytes());
buf.extend(b"\r\n");
if let Some(body) = &self.body {
buf.extend(body);

8
src/main.rs

@ -131,7 +131,7 @@ fn handle_client(mut stream: TlsStream<TcpStream>, static_root: &str) -> Result<
if file_path.has_root() {
// File starts with `/` (*nix) or `\\` (Windows), decline it
return GeminiResponse::not_found().send(stream);
GeminiResponse::not_found().send(stream)
} else {
let path = path::Path::new(&static_root)
.join(&file_path)
@ -148,12 +148,12 @@ fn handle_client(mut stream: TlsStream<TcpStream>, static_root: &str) -> Result<
.ok_or("invalid Unicode".to_owned())?
.to_owned();
return write_file(&index_path).send(stream);
write_file(&index_path).send(stream)
} else {
return write_file(path.to_str().ok_or("invalid Unicode".to_owned())?).send(stream);
write_file(path.to_str().ok_or("invalid Unicode".to_owned())?).send(stream)
}
} else {
return GeminiResponse::not_found().send(stream);
GeminiResponse::not_found().send(stream)
}
}
}

Loading…
Cancel
Save