mirror of
https://github.com/fafhrd91/actix-web
synced 2025-06-27 07:19:04 +02:00
rust 1.64 clippy run (#2891)
This commit is contained in:
@ -682,7 +682,7 @@ mod tests {
|
||||
"/test",
|
||||
web::get().to(|req: HttpRequest| {
|
||||
HttpResponse::Ok()
|
||||
.body(req.url_for("youtube", &["12345"]).unwrap().to_string())
|
||||
.body(req.url_for("youtube", ["12345"]).unwrap().to_string())
|
||||
}),
|
||||
),
|
||||
)
|
||||
|
@ -173,7 +173,7 @@ impl AppInitServiceState {
|
||||
|
||||
#[inline]
|
||||
pub(crate) fn rmap(&self) -> &ResourceMap {
|
||||
&*self.rmap
|
||||
&self.rmap
|
||||
}
|
||||
|
||||
#[inline]
|
||||
|
@ -344,7 +344,7 @@ mod tests {
|
||||
"/test",
|
||||
web::get().to(|req: HttpRequest| {
|
||||
HttpResponse::Ok()
|
||||
.body(req.url_for("youtube", &["12345"]).unwrap().to_string())
|
||||
.body(req.url_for("youtube", ["12345"]).unwrap().to_string())
|
||||
}),
|
||||
),
|
||||
)
|
||||
|
@ -176,7 +176,7 @@ impl str::FromStr for CacheDirective {
|
||||
|
||||
_ => match s.find('=') {
|
||||
Some(idx) if idx + 1 < s.len() => {
|
||||
match (&s[..idx], (&s[idx + 1..]).trim_matches('"')) {
|
||||
match (&s[..idx], s[idx + 1..].trim_matches('"')) {
|
||||
("max-age", secs) => secs.parse().map(MaxAge).map_err(Some),
|
||||
("max-stale", secs) => secs.parse().map(MaxStale).map_err(Some),
|
||||
("min-fresh", secs) => secs.parse().map(MinFresh).map_err(Some),
|
||||
|
@ -219,7 +219,7 @@ impl HttpRequest {
|
||||
/// for urls that do not contain variable parts.
|
||||
pub fn url_for_static(&self, name: &str) -> Result<url::Url, UrlGenerationError> {
|
||||
const NO_PARAMS: [&str; 0] = [];
|
||||
self.url_for(name, &NO_PARAMS)
|
||||
self.url_for(name, NO_PARAMS)
|
||||
}
|
||||
|
||||
/// Get a reference to a `ResourceMap` of current application.
|
||||
@ -306,7 +306,7 @@ impl HttpRequest {
|
||||
|
||||
#[inline]
|
||||
fn app_state(&self) -> &AppInitServiceState {
|
||||
&*self.inner.app_state
|
||||
&self.inner.app_state
|
||||
}
|
||||
|
||||
/// Load request cookies.
|
||||
@ -583,14 +583,14 @@ mod tests {
|
||||
.to_http_request();
|
||||
|
||||
assert_eq!(
|
||||
req.url_for("unknown", &["test"]),
|
||||
req.url_for("unknown", ["test"]),
|
||||
Err(UrlGenerationError::ResourceNotFound)
|
||||
);
|
||||
assert_eq!(
|
||||
req.url_for("index", &["test"]),
|
||||
req.url_for("index", ["test"]),
|
||||
Err(UrlGenerationError::NotEnoughElements)
|
||||
);
|
||||
let url = req.url_for("index", &["test", "html"]);
|
||||
let url = req.url_for("index", ["test", "html"]);
|
||||
assert_eq!(
|
||||
url.ok().unwrap().as_str(),
|
||||
"http://www.rust-lang.org/user/test.html"
|
||||
@ -646,7 +646,7 @@ mod tests {
|
||||
rmap.add(&mut rdef, None);
|
||||
|
||||
let req = TestRequest::default().rmap(rmap).to_http_request();
|
||||
let url = req.url_for("youtube", &["oHg5SJYRHA0"]);
|
||||
let url = req.url_for("youtube", ["oHg5SJYRHA0"]);
|
||||
assert_eq!(
|
||||
url.ok().unwrap().as_str(),
|
||||
"https://youtube.com/watch/oHg5SJYRHA0"
|
||||
|
@ -457,7 +457,7 @@ mod tests {
|
||||
assert_eq!(ct, HeaderValue::from_static("application/json"));
|
||||
assert_body_eq!(res, br#"["v1","v2","v3"]"#);
|
||||
|
||||
let res = HttpResponse::Ok().json(&["v1", "v2", "v3"]);
|
||||
let res = HttpResponse::Ok().json(["v1", "v2", "v3"]);
|
||||
let ct = res.headers().get(CONTENT_TYPE).unwrap();
|
||||
assert_eq!(ct, HeaderValue::from_static("application/json"));
|
||||
assert_body_eq!(res, br#"["v1","v2","v3"]"#);
|
||||
|
@ -449,12 +449,12 @@ mod tests {
|
||||
let req = req.to_http_request();
|
||||
|
||||
let url = rmap
|
||||
.url_for(&req, "post", &["u123", "foobar"])
|
||||
.url_for(&req, "post", ["u123", "foobar"])
|
||||
.unwrap()
|
||||
.to_string();
|
||||
assert_eq!(url, "http://localhost:8888/user/u123/post/foobar");
|
||||
|
||||
assert!(rmap.url_for(&req, "missing", &["u123"]).is_err());
|
||||
assert!(rmap.url_for(&req, "missing", ["u123"]).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -490,7 +490,7 @@ mod tests {
|
||||
assert_eq!(url.path(), OUTPUT);
|
||||
|
||||
assert!(rmap.url_for(&req, "external.2", INPUT).is_err());
|
||||
assert!(rmap.url_for(&req, "external.2", &[""]).is_err());
|
||||
assert!(rmap.url_for(&req, "external.2", [""]).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -524,7 +524,7 @@ mod tests {
|
||||
let req = req.to_http_request();
|
||||
|
||||
assert_eq!(
|
||||
rmap.url_for(&req, "duck", &["abcd"]).unwrap().to_string(),
|
||||
rmap.url_for(&req, "duck", ["abcd"]).unwrap().to_string(),
|
||||
"https://duck.com/abcd"
|
||||
);
|
||||
}
|
||||
@ -552,9 +552,9 @@ mod tests {
|
||||
|
||||
let req = crate::test::TestRequest::default().to_http_request();
|
||||
|
||||
let url = rmap.url_for(&req, "nested", &[""; 0]).unwrap().to_string();
|
||||
let url = rmap.url_for(&req, "nested", [""; 0]).unwrap().to_string();
|
||||
assert_eq!(url, "http://localhost:8080/bar/nested");
|
||||
|
||||
assert!(rmap.url_for(&req, "missing", &["u123"]).is_err());
|
||||
assert!(rmap.url_for(&req, "missing", ["u123"]).is_err());
|
||||
}
|
||||
}
|
||||
|
@ -1133,7 +1133,7 @@ mod tests {
|
||||
"/",
|
||||
web::get().to(|req: HttpRequest| {
|
||||
HttpResponse::Ok()
|
||||
.body(req.url_for("youtube", &["xxxxxx"]).unwrap().to_string())
|
||||
.body(req.url_for("youtube", ["xxxxxx"]).unwrap().to_string())
|
||||
}),
|
||||
);
|
||||
}));
|
||||
@ -1152,8 +1152,7 @@ mod tests {
|
||||
let srv = init_service(App::new().service(web::scope("/a").service(
|
||||
web::scope("/b").service(web::resource("/c/{stuff}").name("c").route(
|
||||
web::get().to(|req: HttpRequest| {
|
||||
HttpResponse::Ok()
|
||||
.body(format!("{}", req.url_for("c", &["12345"]).unwrap()))
|
||||
HttpResponse::Ok().body(format!("{}", req.url_for("c", ["12345"]).unwrap()))
|
||||
}),
|
||||
)),
|
||||
)))
|
||||
|
Reference in New Issue
Block a user