@@ -101,7 +101,7 @@ struct Context<T: ::serde::Serialize> {
101
101
}
102
102
103
103
impl < T : :: serde:: Serialize > Context < T > {
104
- fn new ( page : String , title_id : & str , is_landing : bool , data : T , lang : String ) -> Self {
104
+ fn new ( page : & str , title_id : & str , is_landing : bool , data : T , lang : String ) -> Self {
105
105
let helper = create_loader ( ) ;
106
106
let title = if title_id. is_empty ( ) {
107
107
"" . into ( )
@@ -110,7 +110,7 @@ impl<T: ::serde::Serialize> Context<T> {
110
110
helper. lookup ( & lang, title_id, None )
111
111
} ;
112
112
Self {
113
- page,
113
+ page : page . to_owned ( ) ,
114
114
title,
115
115
parent : LAYOUT ,
116
116
is_landing,
@@ -221,8 +221,8 @@ async fn governance(teams_cache: &Cache<RustTeams>) -> Result<Template, Status>
221
221
222
222
#[ get( "/governance/<section>/<team>" , rank = 2 ) ]
223
223
async fn team (
224
- section : String ,
225
- team : String ,
224
+ section : & str ,
225
+ team : & str ,
226
226
teams_cache : & Cache < RustTeams > ,
227
227
) -> Result < Template , Result < Redirect , Status > > {
228
228
render_team ( section, team, ENGLISH . into ( ) , teams_cache) . await
@@ -238,8 +238,8 @@ async fn governance_locale(
238
238
239
239
#[ get( "/<locale>/governance/<section>/<team>" , rank = 12 ) ]
240
240
async fn team_locale (
241
- section : String ,
242
- team : String ,
241
+ section : & str ,
242
+ team : & str ,
243
243
locale : SupportedLocale ,
244
244
teams_cache : & Cache < RustTeams > ,
245
245
) -> Result < Template , Result < Redirect , Status > > {
@@ -257,14 +257,14 @@ fn production_locale(locale: SupportedLocale) -> Template {
257
257
}
258
258
259
259
#[ get( "/<category>/<subject>" , rank = 4 ) ]
260
- fn subject ( category : Category , subject : String ) -> Result < Template , Status > {
260
+ fn subject ( category : Category , subject : & str ) -> Result < Template , Status > {
261
261
render_subject ( category, subject, ENGLISH . into ( ) )
262
262
}
263
263
264
264
#[ get( "/<locale>/<category>/<subject>" , rank = 14 ) ]
265
265
fn subject_locale (
266
266
category : Category ,
267
- subject : String ,
267
+ subject : & str ,
268
268
locale : SupportedLocale ,
269
269
) -> Result < Template , Status > {
270
270
render_subject ( category, subject, locale. 0 )
@@ -304,7 +304,7 @@ fn not_found(req: &Request) -> Result<Template, Redirect> {
304
304
305
305
fn not_found_locale ( lang : String ) -> Template {
306
306
let page = "404" ;
307
- let context = Context :: new ( "404" . into ( ) , "error404-page-title" , false , ( ) , lang) ;
307
+ let context = Context :: new ( page , "error404-page-title" , false , ( ) , lang) ;
308
308
Template :: render ( page, context)
309
309
}
310
310
@@ -377,7 +377,7 @@ async fn render_index(
377
377
rust_release_post : String ,
378
378
}
379
379
380
- let page = "index" . to_string ( ) ;
380
+ let page = "index" ;
381
381
let release_post = rust_version:: rust_release_post ( release_post_cache) . await ;
382
382
let data = IndexData {
383
383
rust_version : rust_version:: rust_version ( version_cache) . await ,
@@ -387,22 +387,22 @@ async fn render_index(
387
387
String :: new ( )
388
388
} ,
389
389
} ;
390
- let context = Context :: new ( page. clone ( ) , "" , true , data, lang) ;
390
+ let context = Context :: new ( page, "" , true , data, lang) ;
391
391
Template :: render ( page, context)
392
392
}
393
393
394
394
fn render_category ( category : Category , lang : String ) -> Template {
395
395
let page = category. index ( ) ;
396
396
let title_id = format ! ( "{}-page-title" , category. name( ) ) ;
397
- let context = Context :: new ( category. name ( ) . to_string ( ) , & title_id, false , ( ) , lang) ;
397
+ let context = Context :: new ( category. name ( ) , & title_id, false , ( ) , lang) ;
398
398
399
399
Template :: render ( page, context)
400
400
}
401
401
402
402
fn render_production ( lang : String ) -> Template {
403
- let page = "production/users" . to_string ( ) ;
403
+ let page = "production/users" ;
404
404
let context = Context :: new (
405
- page. clone ( ) ,
405
+ page,
406
406
"production-users-page-title" ,
407
407
false ,
408
408
load_users_data ( ) ,
@@ -418,8 +418,8 @@ async fn render_governance(
418
418
) -> Result < Template , Status > {
419
419
match teams:: index_data ( teams_cache) . await {
420
420
Ok ( data) => {
421
- let page = "governance/index" . to_string ( ) ;
422
- let context = Context :: new ( page. clone ( ) , "governance-page-title" , false , data, lang) ;
421
+ let page = "governance/index" ;
422
+ let context = Context :: new ( page, "governance-page-title" , false , data, lang) ;
423
423
424
424
Ok ( Template :: render ( page, context) )
425
425
}
@@ -431,21 +431,21 @@ async fn render_governance(
431
431
}
432
432
433
433
async fn render_team (
434
- section : String ,
435
- team : String ,
434
+ section : & str ,
435
+ team : & str ,
436
436
lang : String ,
437
437
teams_cache : & Cache < RustTeams > ,
438
438
) -> Result < Template , Result < Redirect , Status > > {
439
- match teams:: page_data ( & section, & team, teams_cache) . await {
439
+ match teams:: page_data ( section, team, teams_cache) . await {
440
440
Ok ( data) => {
441
- let page = "governance/group" . to_string ( ) ;
441
+ let page = "governance/group" ;
442
442
let name = format ! ( "governance-team-{}-name" , data. team. name) ;
443
- let context = Context :: new ( page. clone ( ) , & name, false , data, lang) ;
443
+ let context = Context :: new ( page, & name, false , data, lang) ;
444
444
Ok ( Template :: render ( page, context) )
445
445
}
446
446
Err ( err) => {
447
447
if err. is :: < teams:: TeamNotFound > ( ) {
448
- match ( section. as_str ( ) , team. as_str ( ) ) {
448
+ match ( section, team) {
449
449
// Old teams URLs
450
450
( "teams" , "language-and-compiler" ) | ( "teams" , "operations" ) => {
451
451
Err ( Ok ( Redirect :: temporary ( "/governance" ) ) )
@@ -460,7 +460,7 @@ async fn render_team(
460
460
}
461
461
}
462
462
463
- fn render_subject ( category : Category , subject : String , lang : String ) -> Result < Template , Status > {
463
+ fn render_subject ( category : Category , subject : & str , lang : String ) -> Result < Template , Status > {
464
464
// Rocket's Template::render method is not really designed to accept arbitrary templates: if a
465
465
// template is missing, it just returns a Status::InternalServerError, without a way to
466
466
// distinguish it from a syntax error in the template itself.
@@ -473,7 +473,7 @@ fn render_subject(category: Category, subject: String, lang: String) -> Result<T
473
473
return Err ( Status :: NotFound ) ;
474
474
}
475
475
476
- let page = format ! ( "{}/{}" , category. name( ) , subject. as_str ( ) ) ;
476
+ let page = format ! ( "{}/{}" , category. name( ) , subject) ;
477
477
let title_id = format ! ( "{}-{}-page-title" , category. name( ) , subject) ;
478
478
let context = Context :: new ( subject, & title_id, false , ( ) , lang) ;
479
479
0 commit comments