1
0
mirror of https://github.com/actix/examples synced 2025-06-26 17:17:42 +02:00

Use captured args in format string (#558)

This commit is contained in:
Yuri Astrakhan
2022-06-07 22:53:38 -04:00
committed by GitHub
parent 912de4aa46
commit db5f00e771
37 changed files with 57 additions and 60 deletions

View File

@ -7,7 +7,7 @@ use actix_web::{middleware, web, App, HttpRequest, HttpResponse, HttpServer};
/// simple handle
async fn success(enforcer: web::Data<RwLock<Enforcer>>, req: HttpRequest) -> HttpResponse {
let mut e = enforcer.write().await;
println!("{:?}", req);
println!("{req:?}");
assert_eq!(vec!["data2_admin"], e.get_roles_for_user("alice", None));
HttpResponse::Ok().body("Success: alice is data2_admin.")
@ -15,7 +15,7 @@ async fn success(enforcer: web::Data<RwLock<Enforcer>>, req: HttpRequest) -> Htt
async fn fail(enforcer: web::Data<RwLock<Enforcer>>, req: HttpRequest) -> HttpResponse {
let mut e = enforcer.write().await;
println!("{:?}", req);
println!("{req:?}");
assert_eq!(vec!["data1_admin"], e.get_roles_for_user("alice", None));
HttpResponse::Ok().body("Fail: alice is not data1_admin.") // In fact, it can't be displayed.