
[Rust]解決。use of deprecated associated function `actix_web::App::::data`: Use `.app_data(Data::new(val))` instead.
use of deprecated associated function `actix_web::App::<T, B>::data`: Use `.app_data(Data::new(val))` instead.

背景
実戦Rustプログラミング入門をやっていると
ビルド時に
use of deprecated associated function `actix_web::App::<T, B>::data`: Use `.app_data(Data::new(val))` instead.
に言われることがあります。
解決策
「use of deprecated associated function」
そちらはもう廃止な書き方になったので
そこにあるように
app_dataを使いましょうと言うことのようです
.data
になっているところを
to
HttpServer::new(move || App::new().service(index).app_data(pool.clone())).bind(“0.0.0.0:8080”)?
.run().await?;
Ok(())
こちらでそのwaringは消えますが、実施にlocalhostにアクセスすると.dataを使えと言われます。
なので
そのwarningは無視してcargo run。
結果dataを使って表示をさせました