mirror of
https://github.com/actix/actix-website
synced 2025-02-25 05:22:50 +01:00
clippy
This commit is contained in:
parent
1a3fedc78f
commit
5fa564fd4e
@ -1,5 +1,5 @@
|
|||||||
// <helpers>
|
// <helpers>
|
||||||
use actix_web::{error, get, App, HttpServer, Result};
|
use actix_web::{error, get, App, HttpServer};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct MyError {
|
struct MyError {
|
||||||
@ -7,10 +7,10 @@ struct MyError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[get("/")]
|
#[get("/")]
|
||||||
async fn index() -> Result<&'static str> {
|
async fn index() -> actix_web::Result<String> {
|
||||||
let result: Result<&'static str, MyError> = Err(MyError { name: "test error" });
|
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>
|
// </helpers>
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ use actix_web::{get, App, HttpRequest, HttpServer, Responder};
|
|||||||
|
|
||||||
#[get("/")]
|
#[get("/")]
|
||||||
async fn index(req: HttpRequest) -> impl Responder {
|
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");
|
assert_eq!(url.as_str(), "https://youtube.com/watch/oHg5SJYRHA0");
|
||||||
|
|
||||||
url.to_string()
|
url.to_string()
|
||||||
|
@ -3,7 +3,7 @@ use actix_web::{get, guard, http::header, HttpRequest, HttpResponse, Result};
|
|||||||
|
|
||||||
#[get("/test/")]
|
#[get("/test/")]
|
||||||
async fn index(req: HttpRequest) -> Result<HttpResponse> {
|
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()
|
Ok(HttpResponse::Found()
|
||||||
.insert_header((header::LOCATION, url.as_str()))
|
.insert_header((header::LOCATION, url.as_str()))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user