Skip to content
Permalink
Browse files

refactor: apply clippy suggestions

  • Loading branch information...
jkcclemens committed Aug 3, 2019
1 parent 44028de commit 86c499744c6bbec2fe69cfdf155aa149a5fea568
Showing with 6 additions and 6 deletions.
  1. +4 −4 webserver/src/models/user.rs
  2. +2 −2 webserver/src/utils/accept_language.rs
@@ -28,19 +28,19 @@ pub enum AvatarProvider {
}

impl AvatarProvider {
pub fn domain(&self) -> &str {
match *self {
pub fn domain(self) -> &'static str {
match self {
AvatarProvider::Gravatar => "gravatar.com",
AvatarProvider::Libravatar => "seccdn.libravatar.org",
}
}

pub fn hash(&self, s: &str) -> String {
pub fn hash(self, s: &str) -> String {
thread_local! {
static MD5: RefCell<Md5> = RefCell::new(Md5::new());
}

match *self {
match self {
AvatarProvider::Gravatar => MD5.with(|m| {
let mut m = m.borrow_mut();
m.input_str(s);
@@ -24,10 +24,10 @@ impl<'a, 'r> FromRequest<'a, 'r> for AcceptLanguage {
fn from_request(request: &'a Request<'r>) -> request::Outcome<Self, Self::Error> {
let langs = request.headers()
.get("accept-language")
.flat_map(|x| x.split(","))
.flat_map(|x| x.split(','))
// only accept 10 possible languages
.take(10)
.map(|x| x.split(";").next().unwrap().trim())
.map(|x| x.split(';').next().unwrap().trim())
.flat_map(parse_language_identifier)
.collect();
Outcome::Success(AcceptLanguage(langs))

0 comments on commit 86c4997

Please sign in to comment.
You can’t perform that action at this time.