Fix some clippy warnings.

This commit is contained in:
Rasmus Kaj 2022-02-06 20:02:03 +01:00
parent f27ed9b78e
commit ca912afd7c
6 changed files with 12 additions and 12 deletions

View File

@ -122,7 +122,7 @@ fn find_camera(
exif: &ExifData,
) -> Result<Option<Camera>, Error> {
if let Some((make, model)) = exif.camera() {
let cam = Camera::get_or_create(db, &make, &model)?;
let cam = Camera::get_or_create(db, make, model)?;
return Ok(Some(cam));
}
Ok(None)

View File

@ -80,7 +80,7 @@ impl OverpassOpt {
)
.optional()
.map_err(|e| Error::Db(image, e))?
.ok_or_else(|| Error::NoPosition(image))?;
.ok_or(Error::NoPosition(image))?;
debug!("Should get places for #{} at {:?}", image, coord);
let data = Client::new()
.post(&self.overpass_url)

View File

@ -63,15 +63,15 @@ impl PhotosDir {
}
fn load_meta(path: &Path) -> Option<ExifData> {
if let Ok(mut exif) = ExifData::read_from(&path) {
if let Ok(mut exif) = ExifData::read_from(path) {
if exif.width.is_none() || exif.height.is_none() {
if let Ok((width, height)) = actual_image_size(&path) {
if let Ok((width, height)) = actual_image_size(path) {
exif.width = Some(width);
exif.height = Some(height);
}
}
Some(exif)
} else if let Ok((width, height)) = actual_image_size(&path) {
} else if let Ok((width, height)) = actual_image_size(path) {
let mut meta = ExifData::default();
meta.width = Some(width);
meta.height = Some(height);

View File

@ -69,7 +69,7 @@ impl GlobalContext {
}
fn verify_key(&self, jwtstr: &str) -> Result<String, String> {
let token = Token::<Header, ()>::parse(&jwtstr)
let token = Token::<Header, ()>::parse(jwtstr)
.map_err(|e| format!("Bad jwt token: {:?}", e))?;
if !verify_token(&token, self.jwt_secret.as_ref())? {

View File

@ -69,7 +69,7 @@ pub struct Args {
pub async fn run(args: &Args) -> Result<(), Error> {
if let Some(pidfile) = &args.pidfile {
handle_pid_file(&pidfile, args.replace).unwrap()
handle_pid_file(pidfile, args.replace).unwrap()
}
let session_filter = create_session_filter(args);
let s = move || session_filter.clone();

View File

@ -7,9 +7,9 @@ use diesel::pg::{Pg, PgConnection};
use diesel::prelude::*;
use log::{debug, info, warn};
pub fn links_by_time<'a>(
pub fn links_by_time(
context: &Context,
photos: photos::BoxedQuery<'a, Pg>,
photos: photos::BoxedQuery<'_, Pg>,
range: ImgRange,
with_date: bool,
) -> (Vec<PhotoLink>, Vec<(Coord, i32)>) {
@ -42,7 +42,7 @@ pub fn split_to_group_links(
path: &UrlString,
with_date: bool,
) -> Vec<PhotoLink> {
if let Some(groups) = split_to_groups(&photos) {
if let Some(groups) = split_to_groups(photos) {
groups
.iter()
.map(|g| PhotoLink::for_group(g, path.clone(), with_date))
@ -91,8 +91,8 @@ fn find_largest(groups: &[&[Photo]]) -> usize {
let mut found = 0;
let mut largest = 0.0;
for (i, g) in groups.iter().enumerate() {
let time = 1 + g.first().map(|p| timestamp(p)).unwrap_or(0)
- g.last().map(|p| timestamp(p)).unwrap_or(0);
let time = 1 + g.first().map(timestamp).unwrap_or(0)
- g.last().map(timestamp).unwrap_or(0);
let score = (g.len() as f64).powi(3) * (time as f64);
if score > largest {
largest = score;