1919
2020use std:: {
2121 error:: Error ,
22+ fmt:: Write ,
2223 future:: IntoFuture ,
2324 sync:: { Arc , Mutex } ,
2425 time,
@@ -342,7 +343,7 @@ impl Router {
342343 let ssl = match ssl:: Ssl :: new ( acceptor. context ( ) ) {
343344 Ok ( ssl) => ssl,
344345 Err ( e) => {
345- error ! ( "ssl context error: {:?}" , e ) ;
346+ error ! ( "ssl context error: {e :?}" ) ;
346347
347348 return ;
348349 }
@@ -360,14 +361,14 @@ impl Router {
360361 }
361362
362363 if let Err ( e) = self_clone. handle ( & mut stream) . await {
363- error ! ( "handle error: {}" , e ) ;
364+ error ! ( "handle error: {e}" ) ;
364365 }
365366 }
366- Err ( e) => error ! ( "ssl stream error: {:?}" , e ) ,
367+ Err ( e) => error ! ( "ssl stream error: {e :?}" ) ,
367368 }
368369 } ) ;
369370 }
370- Err ( e) => error ! ( "tcp stream error: {:?}" , e ) ,
371+ Err ( e) => error ! ( "tcp stream error: {e :?}" ) ,
371372 }
372373 }
373374
@@ -454,26 +455,29 @@ impl Router {
454455
455456 if let Ok ( mut headers) = self . headers . lock ( ) {
456457 for partial_header in & mut * headers {
457- header. push_str ( & format ! (
458- "{}\n " ,
458+ writeln ! (
459+ & mut header,
460+ "{}" ,
459461 partial_header. call( route_context. clone( ) ) ,
460- ) ) ;
462+ )
463+ . unwrap ( ) ;
461464 }
462465 }
463466
464467 for ( i, partial_footer) in {
465468 #[ allow( clippy:: needless_borrow, clippy:: explicit_auto_deref) ]
466469 ( & mut * self . footers . lock ( ) . unwrap ( ) ) . iter_mut ( ) . enumerate ( )
467470 } {
468- footer. push_str ( & format ! (
471+ let _ = write ! (
472+ & mut footer,
469473 "{}{}" ,
470474 partial_footer. call( route_context. clone( ) ) ,
471475 if footers_length > 1 && i != footers_length - 1 {
472476 "\n "
473477 } else {
474478 ""
475479 } ,
476- ) ) ;
480+ ) ;
477481 }
478482
479483 let mut lock = ( * route. value ) . lock ( ) . await ;
@@ -952,7 +956,7 @@ impl Router {
952956 /// ```rust
953957 /// windmark::router::Router::new().set_port(1965);
954958 /// ```
955- pub fn set_port ( & mut self , port : i32 ) -> & mut Self {
959+ pub const fn set_port ( & mut self , port : i32 ) -> & mut Self {
956960 self . port = port;
957961
958962 self
@@ -966,7 +970,7 @@ impl Router {
966970 /// ```rust
967971 /// windmark::router::Router::new().set_fix_path(true);
968972 /// ```
969- pub fn set_fix_path ( & mut self , fix_path : bool ) -> & mut Self {
973+ pub const fn set_fix_path ( & mut self , fix_path : bool ) -> & mut Self {
970974 self . fix_path = fix_path;
971975
972976 self
0 commit comments