diff --git a/examples/actix_example/src/main.rs b/examples/actix_example/src/main.rs index 00fc5fbc..743244c5 100644 --- a/examples/actix_example/src/main.rs +++ b/examples/actix_example/src/main.rs @@ -14,7 +14,7 @@ mod post; pub use post::Entity as Post; mod setup; -const DEFAULT_POSTS_PER_PAGE: usize = 25; +const DEFAULT_POSTS_PER_PAGE: usize = 5; #[derive(Debug, Clone)] struct AppState { @@ -47,7 +47,7 @@ async fn list( let page = params.page.unwrap_or(1); let posts_per_page = params.posts_per_page.unwrap_or(DEFAULT_POSTS_PER_PAGE); - let paginator = Post::find().paginate(&conn, posts_per_page); + let paginator = Post::find().paginate(conn, posts_per_page); let num_pages = paginator.num_pages().await.ok().unwrap(); let posts = paginator @@ -95,7 +95,7 @@ async fn create( text: Set(form.text.to_owned()), ..Default::default() } - .save(&conn) + .save(conn) .await .expect("could not insert post"); @@ -104,7 +104,7 @@ async fn create( message: "Post successfully added.".to_owned(), }; - actix_flash::Response::with_redirect(flash.clone(), "/") + actix_flash::Response::with_redirect(flash, "/") } #[get("/{id}")] @@ -113,7 +113,7 @@ async fn edit(data: web::Data, id: web::Path) -> Result std::io::Result<()> { let _ = setup::create_post_table(&conn).await; let templates = Tera::new(concat!(env!("CARGO_MANIFEST_DIR"), "/templates/**/*")).unwrap(); let state = AppState { - templates: templates, - conn: conn, + templates, + conn, }; let mut listenfd = ListenFd::from_env();