Fix linter warnings

This commit is contained in:
Malte Tammena 2022-06-26 16:29:21 +02:00
parent 36c8d6adc8
commit 80afb5bd11
5 changed files with 10 additions and 17 deletions

View file

@ -1,5 +1,3 @@
cargo-features = ["edition2021"]
[package]
name = "mensa"
version = "0.5.0"

View file

@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};
use crate::error::Result;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(from = "T", untagged)]
pub enum Fetchable<T> {
/// The value does not exist, but can be fetched.

View file

@ -1,4 +1,3 @@
#![feature(macro_attributes_in_derive_output)]
//! <img src="https://raw.githubusercontent.com/MalteT/mensa/main/static/logo.png" alt="mensa CLI logo" width="400" align="right">
//!
//! [![tests](https://github.com/MalteT/mensa/actions/workflows/rust.yml/badge.svg)](https://github.com/MalteT/mensa/actions/workflows/rust.yml)

View file

@ -14,7 +14,7 @@ mod dummy;
pub use self::dummy::DummyApi as DefaultApi;
/// Assortment of headers relevant to the program.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[non_exhaustive]
pub struct Headers {
pub etag: Option<String>,

View file

@ -55,33 +55,29 @@ impl From<reqwest::header::HeaderMap> for Headers {
use reqwest::header::*;
let etag = map
.get(ETAG)
.map(|raw| {
.and_then(|raw| {
let utf8 = raw.to_str().ok()?;
Some(utf8.to_string())
})
.flatten();
});
let this_page = map
.get("x-current-page")
.map(|raw| {
.and_then(|raw| {
let utf8 = raw.to_str().ok()?;
utf8.parse().ok()
})
.flatten();
});
let next_page = map
.get(LINK)
.map(|raw| {
.and_then(|raw| {
let utf8 = raw.to_str().ok()?;
let captures = LINK_NEXT_PAGE_RE.captures(utf8)?;
Some(captures[1].to_owned())
})
.flatten();
});
let last_page = map
.get("x-total-pages")
.map(|raw| {
.and_then(|raw| {
let utf8 = raw.to_str().ok()?;
utf8.parse().ok()
})
.flatten();
});
Self {
etag,
this_page,