Fix warnings (#464)

This commit is contained in:
Denis Isidoro 2021-04-04 17:42:43 -03:00 committed by GitHub
parent c35e20e778
commit 347c19ddca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 26 additions and 24 deletions

View file

@ -233,9 +233,9 @@ pub fn main(config: Config) -> Result<(), Error> {
let mut writer = display::terminal::Writer::new();
let fetcher: Box<dyn Fetcher> = match config.source() {
Source::CHEATSH(query) => Box::new(cheatsh::Fetcher::new(query)),
Source::TLDR(query) => Box::new(tldr::Fetcher::new(query)),
Source::FILESYSTEM(path) => Box::new(filesystem::Fetcher::new(path)),
Source::Cheats(query) => Box::new(cheatsh::Fetcher::new(query)),
Source::Tldr(query) => Box::new(tldr::Fetcher::new(query)),
Source::Filesystem(path) => Box::new(filesystem::Fetcher::new(path)),
};
let res = fetcher
@ -280,13 +280,13 @@ pub fn main(config: Config) -> Result<(), Error> {
);
match config.action() {
Action::PRINT => {
Action::Print => {
println!("{}", interpolated_snippet);
}
Action::SAVE(filepath) => {
Action::Save(filepath) => {
fs::write(filepath, interpolated_snippet).context("Unable to save output")?;
}
Action::EXECUTE => match key {
Action::Execute => match key {
"ctrl-y" => {
clipboard::copy(interpolated_snippet)?;
}

View file

@ -29,7 +29,10 @@ fn width_with_shell_out() -> u16 {
let stdout = String::from_utf8(output.stdout).expect("Invalid utf8 output from stty");
let mut data = stdout.split_whitespace();
data.next();
u16::from_str_radix(data.next().expect("Not enough data"), 10).expect("Invalid base-10 number")
data.next()
.expect("Not enough data")
.parse::<u16>()
.expect("Invalid base-10 number")
}
_ => FALLBACK_WIDTH,
}

View file

@ -54,7 +54,7 @@ fn get_env_var(name: &str) -> String {
if let Ok(v) = env::var(name) {
v
} else {
panic!(format!("{} not set", name))
panic!("{} not set", name)
}
}

View file

@ -23,8 +23,7 @@ impl VariableMap {
if let Some(v) = self.dependencies.get_mut(&k) {
v.push(fnv(&tags_dependency));
} else {
let mut v: Vec<u64> = Vec::new();
v.push(fnv(&tags_dependency));
let v: Vec<u64> = vec![fnv(&tags_dependency)];
self.dependencies.insert(k, v);
}
}

View file

@ -215,35 +215,35 @@ pub enum AlfredCommand {
}
pub enum Source {
FILESYSTEM(Option<String>),
TLDR(String),
CHEATSH(String),
Filesystem(Option<String>),
Tldr(String),
Cheats(String),
}
pub enum Action {
SAVE(String),
PRINT,
EXECUTE,
Save(String),
Print,
Execute,
}
impl Config {
pub fn source(&self) -> Source {
if let Some(query) = self.tldr.clone() {
Source::TLDR(query)
Source::Tldr(query)
} else if let Some(query) = self.cheatsh.clone() {
Source::CHEATSH(query)
Source::Cheats(query)
} else {
Source::FILESYSTEM(self.path.clone())
Source::Filesystem(self.path.clone())
}
}
pub fn action(&self) -> Action {
if let Some(filepath) = self.save.clone() {
Action::SAVE(filepath)
Action::Save(filepath)
} else if self.print {
Action::PRINT
Action::Print
} else {
Action::EXECUTE
Action::Execute
}
}
@ -254,8 +254,8 @@ impl Config {
}
if self.best_match {
match self.source() {
Source::TLDR(q) => Some(q),
Source::CHEATSH(q) => Some(q),
Source::Tldr(q) => Some(q),
Source::Cheats(q) => Some(q),
_ => Some(String::from("")),
}
} else {