diff --git a/Cargo.toml b/Cargo.toml index e7fb05b9..b80481e8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "www-rust-lang-org" version = "0.1.0" authors = ["The Rust Project Developers"] -edition = "2018" +edition = "2024" [dependencies] handlebars-fluent = "0.4.0" diff --git a/src/cache.rs b/src/cache.rs index f24c94b6..ec5adb61 100644 --- a/src/cache.rs +++ b/src/cache.rs @@ -3,9 +3,9 @@ use std::future::Future; use std::sync::Arc; use std::time::Instant; +use rocket::State; use rocket::tokio::sync::RwLock; use rocket::tokio::task; -use rocket::State; const CACHE_TTL_SECS: u64 = 120; diff --git a/src/caching.rs b/src/caching.rs index d0e067b4..0de9e88a 100644 --- a/src/caching.rs +++ b/src/caching.rs @@ -1,5 +1,5 @@ use rocket::fs::NamedFile; -use rocket::http::{hyper, Header}; +use rocket::http::{Header, hyper}; use rocket::response::Responder; #[derive(Responder)] diff --git a/src/i18n.rs b/src/i18n.rs index e58b6541..a2f8b5c2 100644 --- a/src/i18n.rs +++ b/src/i18n.rs @@ -7,7 +7,7 @@ use serde::Serialize; use std::{collections::HashSet, sync::LazyLock}; use handlebars_fluent::{ - fluent_bundle::{concurrent::FluentBundle, FluentResource, FluentValue}, + fluent_bundle::{FluentResource, FluentValue, concurrent::FluentBundle}, loader::SimpleLoader, simple_loader, }; @@ -19,7 +19,7 @@ fn add_bundle_functions(bundle: &mut FluentBundle<&'static FluentResource>) { bundle .add_function("EMAIL", |values, _named| { let email = match values.first() { - Some(FluentValue::String(ref s)) => s, + Some(FluentValue::String(s)) => s, _ => return FluentValue::None, }; FluentValue::String(format!("{0}", email).into()) @@ -29,7 +29,7 @@ fn add_bundle_functions(bundle: &mut FluentBundle<&'static FluentResource>) { bundle .add_function("ENGLISH", |values, _named| { let text = match values.first() { - Some(FluentValue::String(ref s)) => s, + Some(FluentValue::String(s)) => s, _ => return FluentValue::None, }; FluentValue::String(format!("{0}", text).into()) diff --git a/src/main.rs b/src/main.rs index e72a1d7b..b087a03d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,8 +15,8 @@ use rocket::tokio::sync::RwLock; use rust_version::RustReleasePost; use rust_version::RustVersion; use serde::Serialize; -use teams::encode_zulip_stream; use teams::RustTeams; +use teams::encode_zulip_stream; use std::collections::hash_map::DefaultHasher; use std::env; @@ -30,17 +30,17 @@ use rocket::{ fs::NamedFile, http::Status, request::{FromParam, Request}, - response::{content, Redirect}, + response::{Redirect, content}, }; use rocket_dyn_templates::Template; -use sass_rs::{compile_file, Options}; +use sass_rs::{Options, compile_file}; use category::Category; use caching::CachedNamedFile; -use handlebars_fluent::{loader::Loader, FluentHelper}; -use i18n::{create_loader, LocaleInfo, SupportedLocale, TeamHelper, EXPLICIT_LOCALE_INFO}; +use handlebars_fluent::{FluentHelper, loader::Loader}; +use i18n::{EXPLICIT_LOCALE_INFO, LocaleInfo, SupportedLocale, TeamHelper, create_loader}; const ZULIP_DOMAIN: &str = "https://rust-lang.zulipchat.com"; diff --git a/src/teams.rs b/src/teams.rs index a7179205..24bd5c4c 100644 --- a/src/teams.rs +++ b/src/teams.rs @@ -1,8 +1,8 @@ -use percent_encoding::{utf8_percent_encode, AsciiSet, NON_ALPHANUMERIC}; +use percent_encoding::{AsciiSet, NON_ALPHANUMERIC, utf8_percent_encode}; use rocket_dyn_templates::handlebars::{ Context, Handlebars, Helper, HelperResult, Output, RenderContext, RenderErrorReason, }; -use rust_team_data::v1::{Team, TeamKind, Teams, BASE_URL}; +use rust_team_data::v1::{BASE_URL, Team, TeamKind, Teams}; use serde::Serialize; use std::cmp::Reverse; use std::collections::HashMap; @@ -416,23 +416,26 @@ mod tests { bar.kind = TeamKind::WorkingGroup; let data = Data::dummy(vec![foo, bar]); - assert!(data - .clone() - .page_data("teams", "unknown") - .err() - .unwrap() - .is::()); - assert!(data - .clone() - .page_data("wgs", "foo") - .err() - .unwrap() - .is::()); - assert!(data - .page_data("teams", "bar") - .err() - .unwrap() - .is::()); + assert!( + data.clone() + .page_data("teams", "unknown") + .err() + .unwrap() + .is::() + ); + assert!( + data.clone() + .page_data("wgs", "foo") + .err() + .unwrap() + .is::() + ); + assert!( + data.page_data("teams", "bar") + .err() + .unwrap() + .is::() + ); } #[test] @@ -441,10 +444,11 @@ mod tests { foo.subteam_of = Some("bar".into()); let data = Data::dummy(vec![foo, dummy_team("bar")]); - assert!(data - .page_data("teams", "foo") - .err() - .unwrap() - .is::()); + assert!( + data.page_data("teams", "foo") + .err() + .unwrap() + .is::() + ); } } diff --git a/tests/well_known_security.rs b/tests/well_known_security.rs index fc11d39c..ab212379 100644 --- a/tests/well_known_security.rs +++ b/tests/well_known_security.rs @@ -1,4 +1,4 @@ -use time::{format_description::well_known::Rfc3339, OffsetDateTime}; +use time::{OffsetDateTime, format_description::well_known::Rfc3339}; static TEXT: &str = include_str!("../static/text/well_known_security.txt");