mirror of
https://github.com/actix/actix-website
synced 2024-11-23 16:31:08 +01:00
clippy
This commit is contained in:
parent
1a3fedc78f
commit
5fa564fd4e
@ -1,5 +1,5 @@
|
||||
// <helpers>
|
||||
use actix_web::{error, get, App, HttpServer, Result};
|
||||
use actix_web::{error, get, App, HttpServer};
|
||||
|
||||
#[derive(Debug)]
|
||||
struct MyError {
|
||||
@ -7,10 +7,10 @@ struct MyError {
|
||||
}
|
||||
|
||||
#[get("/")]
|
||||
async fn index() -> Result<&'static str> {
|
||||
let result: Result<&'static str, MyError> = Err(MyError { name: "test error" });
|
||||
async fn index() -> actix_web::Result<String> {
|
||||
let result = Err(MyError { name: "test error" });
|
||||
|
||||
Ok(result.map_err(|e| error::ErrorBadRequest(e.name))?)
|
||||
result.map_err(|err| error::ErrorBadRequest(err.name))
|
||||
}
|
||||
// </helpers>
|
||||
|
||||
|
@ -3,7 +3,7 @@ use actix_web::{get, App, HttpRequest, HttpServer, Responder};
|
||||
|
||||
#[get("/")]
|
||||
async fn index(req: HttpRequest) -> impl Responder {
|
||||
let url = req.url_for("youtube", &["oHg5SJYRHA0"]).unwrap();
|
||||
let url = req.url_for("youtube", ["oHg5SJYRHA0"]).unwrap();
|
||||
assert_eq!(url.as_str(), "https://youtube.com/watch/oHg5SJYRHA0");
|
||||
|
||||
url.to_string()
|
||||
|
@ -3,7 +3,7 @@ use actix_web::{get, guard, http::header, HttpRequest, HttpResponse, Result};
|
||||
|
||||
#[get("/test/")]
|
||||
async fn index(req: HttpRequest) -> Result<HttpResponse> {
|
||||
let url = req.url_for("foo", &["1", "2", "3"])?; // <- generate url for "foo" resource
|
||||
let url = req.url_for("foo", ["1", "2", "3"])?; // <- generate url for "foo" resource
|
||||
|
||||
Ok(HttpResponse::Found()
|
||||
.insert_header((header::LOCATION, url.as_str()))
|
||||
|
Loading…
Reference in New Issue
Block a user