summaryrefslogtreecommitdiffstats
path: root/src/main.rs
diff options
context:
space:
mode:
authorSam Tay <sam.chong.tay@gmail.com>2020-06-07 13:34:16 -0700
committerSam Tay <sam.chong.tay@gmail.com>2020-06-07 13:34:16 -0700
commit1942882d2825b205cec89c8cb5990d637ebdf838 (patch)
treed34f18d1ceafc1d9d2fd519bef03e933398d2fd9 /src/main.rs
parent799936479d3e80237c6e6595baade9737e137011 (diff)
Thank god for clippy
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/main.rs b/src/main.rs
index e48323d..0f390df 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -24,7 +24,7 @@ fn main() {
if opts.list_sites {
let sites = ls.sites()?;
- match sites.into_iter().map(|s| s.api_site_parameter.len()).max() {
+ match sites.iter().map(|s| s.api_site_parameter.len()).max() {
Some(max_w) => {
for s in sites {
println!("{:>w$}: {}", s.api_site_parameter, s.site_url, w = max_w);
@@ -75,19 +75,23 @@ fn main() {
let que = se.search(&q)?;
let ans = que
.first()
- .ok_or(Error::no_results())?
+ .ok_or_else(Error::no_results)?
.answers
.first()
- .ok_or(Error::from(
- "StackExchange returned a question with no answers; this shouldn't be possible!",
- ))?;
+ .ok_or_else(|| {
+ Error::from(
+ "StackExchange returned a question with no answers; \
+ this shouldn't be possible!",
+ )
+ })?;
println!("{}", ans.body);
}
Ok(())
})()
- .unwrap_or_else(|e| match e {
- Error { error, .. } => printerr!(error),
+ .unwrap_or_else(|e| {
+ let Error { error, .. } = e;
+ printerr!(error);
})
}