@@ -101,7 +101,7 @@ struct Context<T: ::serde::Serialize> {
101101}
102102
103103impl < 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 {
105105 let helper = create_loader ( ) ;
106106 let title = if title_id. is_empty ( ) {
107107 "" . into ( )
@@ -110,7 +110,7 @@ impl<T: ::serde::Serialize> Context<T> {
110110 helper. lookup ( & lang, title_id, None )
111111 } ;
112112 Self {
113- page,
113+ page : page . to_owned ( ) ,
114114 title,
115115 parent : LAYOUT ,
116116 is_landing,
@@ -221,8 +221,8 @@ async fn governance(teams_cache: &Cache<RustTeams>) -> Result<Template, Status>
221221
222222#[ get( "/governance/<section>/<team>" , rank = 2 ) ]
223223async fn team (
224- section : String ,
225- team : String ,
224+ section : & str ,
225+ team : & str ,
226226 teams_cache : & Cache < RustTeams > ,
227227) -> Result < Template , Result < Redirect , Status > > {
228228 render_team ( section, team, ENGLISH . into ( ) , teams_cache) . await
@@ -238,8 +238,8 @@ async fn governance_locale(
238238
239239#[ get( "/<locale>/governance/<section>/<team>" , rank = 12 ) ]
240240async fn team_locale (
241- section : String ,
242- team : String ,
241+ section : & str ,
242+ team : & str ,
243243 locale : SupportedLocale ,
244244 teams_cache : & Cache < RustTeams > ,
245245) -> Result < Template , Result < Redirect , Status > > {
@@ -257,14 +257,14 @@ fn production_locale(locale: SupportedLocale) -> Template {
257257}
258258
259259#[ 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 > {
261261 render_subject ( category, subject, ENGLISH . into ( ) )
262262}
263263
264264#[ get( "/<locale>/<category>/<subject>" , rank = 14 ) ]
265265fn subject_locale (
266266 category : Category ,
267- subject : String ,
267+ subject : & str ,
268268 locale : SupportedLocale ,
269269) -> Result < Template , Status > {
270270 render_subject ( category, subject, locale. 0 )
@@ -304,7 +304,7 @@ fn not_found(req: &Request) -> Result<Template, Redirect> {
304304
305305fn not_found_locale ( lang : String ) -> Template {
306306 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) ;
308308 Template :: render ( page, context)
309309}
310310
@@ -377,7 +377,7 @@ async fn render_index(
377377 rust_release_post : String ,
378378 }
379379
380- let page = "index" . to_string ( ) ;
380+ let page = "index" ;
381381 let release_post = rust_version:: rust_release_post ( release_post_cache) . await ;
382382 let data = IndexData {
383383 rust_version : rust_version:: rust_version ( version_cache) . await ,
@@ -387,22 +387,22 @@ async fn render_index(
387387 String :: new ( )
388388 } ,
389389 } ;
390- let context = Context :: new ( page. clone ( ) , "" , true , data, lang) ;
390+ let context = Context :: new ( page, "" , true , data, lang) ;
391391 Template :: render ( page, context)
392392}
393393
394394fn render_category ( category : Category , lang : String ) -> Template {
395395 let page = category. index ( ) ;
396396 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) ;
398398
399399 Template :: render ( page, context)
400400}
401401
402402fn render_production ( lang : String ) -> Template {
403- let page = "production/users" . to_string ( ) ;
403+ let page = "production/users" ;
404404 let context = Context :: new (
405- page. clone ( ) ,
405+ page,
406406 "production-users-page-title" ,
407407 false ,
408408 load_users_data ( ) ,
@@ -418,8 +418,8 @@ async fn render_governance(
418418) -> Result < Template , Status > {
419419 match teams:: index_data ( teams_cache) . await {
420420 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) ;
423423
424424 Ok ( Template :: render ( page, context) )
425425 }
@@ -431,21 +431,21 @@ async fn render_governance(
431431}
432432
433433async fn render_team (
434- section : String ,
435- team : String ,
434+ section : & str ,
435+ team : & str ,
436436 lang : String ,
437437 teams_cache : & Cache < RustTeams > ,
438438) -> 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 {
440440 Ok ( data) => {
441- let page = "governance/group" . to_string ( ) ;
441+ let page = "governance/group" ;
442442 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) ;
444444 Ok ( Template :: render ( page, context) )
445445 }
446446 Err ( err) => {
447447 if err. is :: < teams:: TeamNotFound > ( ) {
448- match ( section. as_str ( ) , team. as_str ( ) ) {
448+ match ( section, team) {
449449 // Old teams URLs
450450 ( "teams" , "language-and-compiler" ) | ( "teams" , "operations" ) => {
451451 Err ( Ok ( Redirect :: temporary ( "/governance" ) ) )
@@ -460,7 +460,7 @@ async fn render_team(
460460 }
461461}
462462
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 > {
464464 // Rocket's Template::render method is not really designed to accept arbitrary templates: if a
465465 // template is missing, it just returns a Status::InternalServerError, without a way to
466466 // 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
473473 return Err ( Status :: NotFound ) ;
474474 }
475475
476- let page = format ! ( "{}/{}" , category. name( ) , subject. as_str ( ) ) ;
476+ let page = format ! ( "{}/{}" , category. name( ) , subject) ;
477477 let title_id = format ! ( "{}-{}-page-title" , category. name( ) , subject) ;
478478 let context = Context :: new ( subject, & title_id, false , ( ) , lang) ;
479479
0 commit comments