aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortilpner2019-05-03 14:13:23 +0200
committertilpner2019-05-03 14:13:23 +0200
commit9a1e4be71a7cf47dfd921e4913b587ad299d9aee (patch)
tree3acb82926aa1be47920ffc55a0b5fe2d14601ce4
parent5efea0b210b8e4ad696d8df50278710062bcdb18 (diff)
downloadrpb-s3-9a1e4be71a7cf47dfd921e4913b587ad299d9aee.tar.gz
rpb-s3-9a1e4be71a7cf47dfd921e4913b587ad299d9aee.tar.xz
rpb-s3-9a1e4be71a7cf47dfd921e4913b587ad299d9aee.zip
Clean unused imports and expect/ignore results
-rw-r--r--src/base62.rs4
-rw-r--r--src/main.rs39
2 files changed, 18 insertions, 25 deletions
diff --git a/src/base62.rs b/src/base62.rs
index 6ec1e62..a556b13 100644
--- a/src/base62.rs
+++ b/src/base62.rs
@@ -1,6 +1,3 @@
-use std::iter;
-use itertools;
-
pub const BASE: u8 = 62;
pub const ALPHABET: &'static [u8; BASE as usize] =
b"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
@@ -17,6 +14,7 @@ pub fn number_to_digits(mut x: u128, base: u8) -> Vec<u8> {
out
}
+#[allow(dead_code)]
pub fn digits_to_number<I>(x: I, base: u8) -> u128
where I: Iterator<Item=u8> {
let base = base as u128;
diff --git a/src/main.rs b/src/main.rs
index f1f0ae2..c50f44f 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -4,28 +4,22 @@ use std::{
env, iter,
fs::File,
io::{ self, Read, BufRead, BufReader, Write },
- iter::FromIterator,
- path::PathBuf,
- sync::Arc,
- collections::HashMap
+ path::PathBuf
};
-use itertools::{ self, Itertools };
-use url::Url;
+use itertools;
use rand;
-use serde::{ Serialize, Deserialize };
-use serde_value::to_value;
-use config::{ Config, Source };
+use config::Config;
use structopt::{ StructOpt, clap::ArgGroup };
use mime_guess::{ Mime, guess_mime_type_opt };
-use futures::{ stream, Future };
+use futures::stream;
use rusoto_core::{
request,
Region, ByteStream,
- credential::{ ProvideAwsCredentials, StaticProvider }
+ credential::StaticProvider
};
use rusoto_s3::{
S3, S3Client,
@@ -84,13 +78,14 @@ fn main() {
.or(xdg_file);
if let Some(cfg_file) = cfg_file {
let cfg_file = cfg_file.to_str().expect("Config file has invalid path");
- cfg.merge(config::File::new(cfg_file, config::FileFormat::Json));
+ cfg.merge(config::File::new(cfg_file, config::FileFormat::Json))
+ .expect("Failed to read settings from config file");
}
cfg.merge(config::Environment::with_prefix("PB")).expect("Failed to read config from environment");
cfg.merge(Config::try_from(&opt).unwrap()).expect("Failed to read config from CLI arguments");
if cfg.get_bool("private").unwrap_or(false) {
- cfg.set("id_length", 10);
+ cfg.set("id_length", 10).unwrap();
}
cfg
};
@@ -145,7 +140,7 @@ fn main() {
.unwrap_or_else(|| String::from("text/plain; charset=utf-8"))
};
- let put = client.put_object(PutObjectRequest {
+ let _put = client.put_object(PutObjectRequest {
bucket,
key: name.clone(),
content_type: Some(mime),
@@ -171,7 +166,7 @@ fn highlight(cfg: &Config, mut input: Box<dyn BufRead + Send>) -> impl Iterator<
use tinytemplate::TinyTemplate;
let mut input_str = String::new();
- input.read_to_string(&mut input_str);
+ input.read_to_string(&mut input_str).expect("Unable to read input");
let mut syntax_set = SyntaxSet::load_defaults_newlines().into_builder();
syntax_set.add(SyntaxDefinition::load_from_str(include_str!("../syntax/nix.sublime-syntax"), false, None)
@@ -200,23 +195,23 @@ fn highlight(cfg: &Config, mut input: Box<dyn BufRead + Send>) -> impl Iterator<
let mut html = Vec::new();
let mut formatted_line = String::new();
let (_, bg) = start_highlighted_html_snippet(theme);
- write!(&mut html, "<table><tr><td unselectable=\"on\"><pre class=linenumbers>");
- for (i, line) in input_str.lines().enumerate() {
- writeln!(&mut html, "<a href=\"#L{}\">{}</a>", i, i);
+ let _ = write!(&mut html, "<table><tr><td unselectable=\"on\"><pre class=linenumbers>");
+ for (i, _line) in input_str.lines().enumerate() {
+ let _ = writeln!(&mut html, "<a href=\"#L{}\">{}</a>", i, i);
}
- write!(&mut html, "</pre></td><td><pre class=code><code>");
+ let _ = write!(&mut html, "</pre></td><td><pre class=code><code>");
for (i, line) in LinesWithEndings::from(&input_str).enumerate() {
let regions = highlighter.highlight(line, &syntax_set);
formatted_line.clear();
append_highlighted_html_for_styled_line(&regions[..], IncludeBackground::IfDifferent(bg), &mut formatted_line);
if formatted_line.ends_with('\n') { formatted_line.pop(); }
- write!(&mut html, "<a id=\"L{}\"></a>{}", i, formatted_line);
+ let _ = write!(&mut html, "<a id=\"L{}\"></a>{}", i, formatted_line);
}
- write!(&mut html, "</code></pre></td></tr></table>");
+ let _ = write!(&mut html, "</code></pre></td></tr></table>");
let mut template = TinyTemplate::new();
- template.add_template("code", TEMPLATE);
+ template.add_template("code", TEMPLATE).expect("Template is faulty");
template.add_formatter("raw", tinytemplate::format_unescaped);
let rendered = template.render("code", &Template {