mirror of
https://github.com/Orange-OpenSource/hurl.git
synced 2024-11-26 00:22:10 +03:00
Remove some unncessary clones.
This commit is contained in:
parent
aed9addcb5
commit
decac0a685
@ -34,25 +34,25 @@ pub fn eval_query(
|
||||
variables: &HashMap<String, Value>,
|
||||
response: &http::Response,
|
||||
) -> QueryResult {
|
||||
match query.value.clone() {
|
||||
match &query.value {
|
||||
QueryValue::Status => eval_query_status(response),
|
||||
QueryValue::Url => eval_query_url(response),
|
||||
QueryValue::Header { name, .. } => eval_query_header(response, &name, variables),
|
||||
QueryValue::Header { name, .. } => eval_query_header(response, name, variables),
|
||||
QueryValue::Cookie {
|
||||
expr: CookiePath { name, attribute },
|
||||
..
|
||||
} => eval_query_cookie(response, &name, &attribute, variables),
|
||||
} => eval_query_cookie(response, name, attribute, variables),
|
||||
QueryValue::Body => eval_query_body(response, query.source_info),
|
||||
QueryValue::Xpath { expr, .. } => {
|
||||
eval_query_xpath(response, &expr, variables, query.source_info)
|
||||
eval_query_xpath(response, expr, variables, query.source_info)
|
||||
}
|
||||
QueryValue::Jsonpath { expr, .. } => {
|
||||
eval_query_jsonpath(response, &expr, variables, query.source_info)
|
||||
eval_query_jsonpath(response, expr, variables, query.source_info)
|
||||
}
|
||||
QueryValue::Regex { value, .. } => {
|
||||
eval_query_regex(response, &value, variables, query.source_info)
|
||||
eval_query_regex(response, value, variables, query.source_info)
|
||||
}
|
||||
QueryValue::Variable { name, .. } => eval_query_variable(&name, variables),
|
||||
QueryValue::Variable { name, .. } => eval_query_variable(name, variables),
|
||||
QueryValue::Duration => eval_query_duration(response),
|
||||
QueryValue::Bytes => eval_query_bytes(response, query.source_info),
|
||||
QueryValue::Sha256 => eval_query_sha256(response, query.source_info),
|
||||
@ -60,7 +60,7 @@ pub fn eval_query(
|
||||
QueryValue::Certificate {
|
||||
attribute_name: field,
|
||||
..
|
||||
} => eval_query_certificate(response, field),
|
||||
} => eval_query_certificate(response, *field),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -143,7 +143,7 @@ pub fn eval_asserts(
|
||||
}
|
||||
|
||||
// Then, checks all the explicit asserts.
|
||||
for assert in &response.asserts() {
|
||||
for assert in response.asserts() {
|
||||
let assert_result =
|
||||
assert::eval_explicit_assert(assert, variables, http_response, context_dir);
|
||||
asserts.push(assert_result);
|
||||
@ -351,7 +351,7 @@ pub fn eval_captures(
|
||||
variables: &mut HashMap<String, Value>,
|
||||
) -> Result<Vec<CaptureResult>, RunnerError> {
|
||||
let mut captures = vec![];
|
||||
for capture in &response.captures() {
|
||||
for capture in response.captures() {
|
||||
let capture_result = capture::eval_capture(capture, variables, http_response)?;
|
||||
// Update variables now so the captures set is ready in case
|
||||
// the next captures reference this new variable.
|
||||
|
@ -125,23 +125,23 @@ pub struct Response {
|
||||
|
||||
impl Response {
|
||||
/// Returns the captures list of this spec response.
|
||||
pub fn captures(&self) -> Vec<Capture> {
|
||||
pub fn captures(&self) -> &[Capture] {
|
||||
for section in self.sections.iter() {
|
||||
if let SectionValue::Captures(captures) = §ion.value {
|
||||
return captures.clone();
|
||||
return captures;
|
||||
}
|
||||
}
|
||||
vec![]
|
||||
&[]
|
||||
}
|
||||
|
||||
/// Returns the asserts list of this spec response.
|
||||
pub fn asserts(&self) -> Vec<Assert> {
|
||||
pub fn asserts(&self) -> &[Assert] {
|
||||
for section in self.sections.iter() {
|
||||
if let SectionValue::Asserts(asserts) = §ion.value {
|
||||
return asserts.clone();
|
||||
return asserts;
|
||||
}
|
||||
}
|
||||
vec![]
|
||||
&[]
|
||||
}
|
||||
}
|
||||
|
||||
@ -390,7 +390,7 @@ impl CookieAttributeName {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
pub enum CertificateAttributeName {
|
||||
Subject,
|
||||
Issuer,
|
||||
|
@ -279,7 +279,7 @@ fn lint_query_value(query_value: &QueryValue) -> QueryValue {
|
||||
attribute_name: field,
|
||||
..
|
||||
} => QueryValue::Certificate {
|
||||
attribute_name: field.clone(),
|
||||
attribute_name: *field,
|
||||
space0: one_whitespace(),
|
||||
},
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user