mirror of
https://github.com/Orange-OpenSource/hurl.git
synced 2024-11-30 10:56:09 +03:00
Add clippy check manual_string_new
This commit is contained in:
parent
a4c6d610d9
commit
73759aa84b
@ -1,8 +1,9 @@
|
||||
#!/bin/bash
|
||||
set -Eeuo pipefail
|
||||
|
||||
# https://rust-lang.github.io/rust-clippy/master/index.html
|
||||
cargo clippy -- \
|
||||
--deny warnings \
|
||||
--deny clippy::empty_structs_with_brackets # https://rust-lang.github.io/rust-clippy/master/index.html#/empty_structs_with_brackets
|
||||
--deny clippy::empty_structs_with_brackets \
|
||||
--deny clippy::manual_string_new
|
||||
|
||||
|
||||
|
@ -95,7 +95,7 @@ fn log_request(request: Request) {
|
||||
if let Some(content_type) = file_param.value.content_type {
|
||||
format!("; {content_type}")
|
||||
} else {
|
||||
"".to_string()
|
||||
String::new()
|
||||
};
|
||||
eprintln!(
|
||||
"\r{}: {}{}",
|
||||
|
@ -129,7 +129,7 @@ pub fn html_unescape(text: &str) -> String {
|
||||
return "\u{FFFD}".to_string();
|
||||
}
|
||||
if INVALID_CODEPOINTS.contains(&num) {
|
||||
return "".to_string();
|
||||
return String::new();
|
||||
}
|
||||
char::from_u32(num).unwrap().to_string()
|
||||
} else {
|
||||
|
@ -788,10 +788,10 @@ mod tests {
|
||||
domain: "example.com".to_string(),
|
||||
include_subdomain: "FALSE".to_string(),
|
||||
path: "/".to_string(),
|
||||
https: "".to_string(),
|
||||
expires: "".to_string(),
|
||||
name: "".to_string(),
|
||||
value: "".to_string(),
|
||||
https: String::new(),
|
||||
expires: String::new(),
|
||||
name: String::new(),
|
||||
value: String::new(),
|
||||
http_only: false,
|
||||
};
|
||||
assert!(match_cookie(&cookie, "http://example.com/toto"));
|
||||
@ -802,10 +802,10 @@ mod tests {
|
||||
domain: "example.com".to_string(),
|
||||
include_subdomain: "TRUE".to_string(),
|
||||
path: "/toto".to_string(),
|
||||
https: "".to_string(),
|
||||
expires: "".to_string(),
|
||||
name: "".to_string(),
|
||||
value: "".to_string(),
|
||||
https: String::new(),
|
||||
expires: String::new(),
|
||||
name: String::new(),
|
||||
value: String::new(),
|
||||
http_only: false,
|
||||
};
|
||||
assert!(match_cookie(&cookie, "http://example.com/toto"));
|
||||
|
@ -176,7 +176,7 @@ pub mod tests {
|
||||
}
|
||||
);
|
||||
|
||||
assert_eq!(CookieAttribute::parse("".to_string()), None);
|
||||
assert_eq!(CookieAttribute::parse(String::new()), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -358,7 +358,7 @@ pub mod tests {
|
||||
},
|
||||
CookieAttribute {
|
||||
name: "Max-Age".to_string(),
|
||||
value: Some("".to_string()),
|
||||
value: Some(String::new()),
|
||||
},
|
||||
],
|
||||
};
|
||||
|
@ -139,7 +139,7 @@ impl FromStr for Cookie {
|
||||
let value = if let Some(&v) = tokens.get(6) {
|
||||
v.to_string()
|
||||
} else {
|
||||
"".to_string()
|
||||
String::new()
|
||||
};
|
||||
Ok(Cookie {
|
||||
domain,
|
||||
@ -182,7 +182,7 @@ mod tests {
|
||||
https: "FALSE".to_string(),
|
||||
expires: "1".to_string(),
|
||||
name: "cookie2".to_string(),
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
http_only: false,
|
||||
}
|
||||
);
|
||||
|
@ -44,7 +44,7 @@ pub fn log_bytes(bytes: &[u8], max: usize, debug: bool, logger: &Logger) {
|
||||
};
|
||||
|
||||
let log = if bytes.is_empty() {
|
||||
"".to_string()
|
||||
String::new()
|
||||
} else {
|
||||
format!("Bytes <{}...>", hex::encode(bytes))
|
||||
};
|
||||
|
@ -48,7 +48,7 @@ impl From<curl::Error> for HttpError {
|
||||
fn from(err: curl::Error) -> Self {
|
||||
let code = err.code() as i32;
|
||||
let description = err.description().to_string();
|
||||
let url = "".to_string();
|
||||
let url = String::new();
|
||||
HttpError::Libcurl {
|
||||
code,
|
||||
description,
|
||||
|
@ -78,7 +78,7 @@ impl Request {
|
||||
};
|
||||
let port = match url.port() {
|
||||
Some(port) => format!(":{port}"),
|
||||
None => "".to_string(),
|
||||
None => String::new(),
|
||||
};
|
||||
Ok(format!("{scheme}://{host}{port}"))
|
||||
}
|
||||
@ -96,7 +96,7 @@ fn parse_cookie(s: &str) -> RequestCookie {
|
||||
},
|
||||
None => RequestCookie {
|
||||
name: s.to_string(),
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -149,7 +149,7 @@ mod tests {
|
||||
},
|
||||
Param {
|
||||
name: "param2".to_string(),
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
},
|
||||
Param {
|
||||
name: "param3".to_string(),
|
||||
@ -214,7 +214,7 @@ mod tests {
|
||||
assert_eq!(
|
||||
Request {
|
||||
url: "http://localhost".to_string(),
|
||||
method: "".to_string(),
|
||||
method: String::new(),
|
||||
headers: vec![],
|
||||
body: vec![],
|
||||
}
|
||||
@ -225,7 +225,7 @@ mod tests {
|
||||
assert_eq!(
|
||||
Request {
|
||||
url: "http://localhost:8000/redirect-relative".to_string(),
|
||||
method: "".to_string(),
|
||||
method: String::new(),
|
||||
headers: vec![],
|
||||
body: vec![],
|
||||
}
|
||||
@ -236,7 +236,7 @@ mod tests {
|
||||
assert_eq!(
|
||||
Request {
|
||||
url: "https://localhost:8000".to_string(),
|
||||
method: "".to_string(),
|
||||
method: String::new(),
|
||||
headers: vec![],
|
||||
body: vec![],
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ impl Default for RequestSpec {
|
||||
fn default() -> Self {
|
||||
RequestSpec {
|
||||
method: Method("GET".to_string()),
|
||||
url: "".to_string(),
|
||||
url: String::new(),
|
||||
headers: vec![],
|
||||
querystring: vec![],
|
||||
form: vec![],
|
||||
|
@ -102,7 +102,7 @@ impl RequestSpec {
|
||||
}
|
||||
|
||||
let querystring = if self.querystring.is_empty() {
|
||||
"".to_string()
|
||||
String::new()
|
||||
} else {
|
||||
let params = self
|
||||
.querystring
|
||||
@ -243,7 +243,7 @@ fn escape_string(s: &str) -> String {
|
||||
escaped_sequences.insert('\'', "\\'");
|
||||
escaped_sequences.insert('\\', "\\\\");
|
||||
|
||||
let mut escaped = "".to_string();
|
||||
let mut escaped = String::new();
|
||||
for c in s.chars() {
|
||||
match escaped_sequences.get(&c) {
|
||||
None => escaped.push(c),
|
||||
@ -340,7 +340,7 @@ pub mod tests {
|
||||
assert_eq!(
|
||||
Param {
|
||||
name: "param2".to_string(),
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
}
|
||||
.curl_arg(),
|
||||
"param2=".to_string()
|
||||
|
@ -42,7 +42,7 @@ impl Default for Response {
|
||||
headers: vec![],
|
||||
body: vec![],
|
||||
duration: Default::default(),
|
||||
url: "".to_string(),
|
||||
url: String::new(),
|
||||
certificate: None,
|
||||
}
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ pub fn number(reader: &mut Reader) -> ParseResult<'static, Number> {
|
||||
|
||||
pub fn string_value(reader: &mut Reader) -> Result<String, Error> {
|
||||
try_literal("'", reader)?;
|
||||
let mut s = "".to_string();
|
||||
let mut s = String::new();
|
||||
loop {
|
||||
match reader.read() {
|
||||
None => {
|
||||
|
@ -70,7 +70,7 @@ impl Reader {
|
||||
/// Returns `count` chars from the buffer advancing the internal state.
|
||||
/// This methods can returns less than `count` chars if there is not enough chars in the buffer.
|
||||
pub fn read_n(&mut self, count: usize) -> String {
|
||||
let mut s = String::from("");
|
||||
let mut s = String::new();
|
||||
for _ in 0..count {
|
||||
match self.read() {
|
||||
None => {}
|
||||
@ -82,7 +82,7 @@ impl Reader {
|
||||
|
||||
/// Returns chars from the buffer while `predicate` is true, advancing the internal state.
|
||||
pub fn read_while(&mut self, predicate: fn(&char) -> bool) -> String {
|
||||
let mut s = String::from("");
|
||||
let mut s = String::new();
|
||||
loop {
|
||||
match self.peek() {
|
||||
None => return s,
|
||||
|
@ -342,8 +342,8 @@ pub mod tests {
|
||||
compressed: false,
|
||||
};
|
||||
HurlRun {
|
||||
content: "".to_string(),
|
||||
filename: "".to_string(),
|
||||
content: String::new(),
|
||||
filename: String::new(),
|
||||
hurl_result: HurlResult {
|
||||
entries: vec![dummy_entry; entries_count],
|
||||
time_in_ms: 0,
|
||||
|
@ -78,7 +78,7 @@ pub fn write_body(
|
||||
}
|
||||
} else {
|
||||
let source = if filename_in == "-" {
|
||||
"".to_string()
|
||||
String::new()
|
||||
} else {
|
||||
format!("for file {filename_in}")
|
||||
};
|
||||
|
@ -56,7 +56,7 @@ impl Testcase {
|
||||
let times = get_times_interval(calls);
|
||||
let times = match times {
|
||||
Some(t) => t,
|
||||
None => return "".to_string(),
|
||||
None => return String::new(),
|
||||
};
|
||||
|
||||
let margin_top = 50.px();
|
||||
|
@ -73,7 +73,7 @@ pub mod tests {
|
||||
pub fn user_count_capture() -> Capture {
|
||||
// non scalar value
|
||||
let whitespace = Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(0, 0, 0, 0),
|
||||
};
|
||||
Capture {
|
||||
@ -102,7 +102,7 @@ pub mod tests {
|
||||
pub fn duration_capture() -> Capture {
|
||||
// non scalar value
|
||||
let whitespace = Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(0, 0, 0, 0),
|
||||
};
|
||||
Capture {
|
||||
@ -132,7 +132,7 @@ pub mod tests {
|
||||
fn test_invalid_xpath() {
|
||||
let variables = HashMap::new();
|
||||
let whitespace = Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(0, 0, 0, 0),
|
||||
};
|
||||
let capture = Capture {
|
||||
@ -167,7 +167,7 @@ pub mod tests {
|
||||
fn test_capture_unsupported() {
|
||||
// non scalar value
|
||||
let whitespace = Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(0, 0, 0, 0),
|
||||
};
|
||||
let _capture = Capture {
|
||||
|
@ -633,7 +633,7 @@ pub mod tests {
|
||||
|
||||
let variables = HashMap::new();
|
||||
let whitespace = Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(0, 0, 0, 0),
|
||||
};
|
||||
let filter = Filter {
|
||||
@ -668,7 +668,7 @@ pub mod tests {
|
||||
// regex "Hello (.*)!"
|
||||
let variables = HashMap::new();
|
||||
let whitespace = Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(0, 0, 0, 0),
|
||||
};
|
||||
let filter = Filter {
|
||||
@ -711,7 +711,7 @@ pub mod tests {
|
||||
fn eval_filter_invalid_regex() {
|
||||
let variables = HashMap::new();
|
||||
let whitespace = Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(0, 0, 0, 0),
|
||||
};
|
||||
let filter = Filter {
|
||||
@ -914,7 +914,7 @@ pub mod tests {
|
||||
value: FilterValue::Nth {
|
||||
n: 2,
|
||||
space0: Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(0, 0, 0, 0),
|
||||
},
|
||||
},
|
||||
@ -976,11 +976,11 @@ pub mod tests {
|
||||
source_info: SourceInfo::new(0, 0, 0, 0),
|
||||
},
|
||||
space0: Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(0, 0, 0, 0),
|
||||
},
|
||||
space1: Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(0, 0, 0, 0),
|
||||
},
|
||||
},
|
||||
@ -1014,7 +1014,7 @@ pub mod tests {
|
||||
source_info: SourceInfo::new(0, 0, 0, 0),
|
||||
},
|
||||
space0: Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(0, 0, 0, 0),
|
||||
},
|
||||
},
|
||||
@ -1053,7 +1053,7 @@ pub mod tests {
|
||||
source_info: SourceInfo::new(0, 0, 0, 0),
|
||||
},
|
||||
space0: Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(0, 0, 0, 0),
|
||||
},
|
||||
},
|
||||
@ -1088,7 +1088,7 @@ pub mod tests {
|
||||
source_info: SourceInfo::new(0, 0, 0, 0),
|
||||
},
|
||||
space0: Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(0, 0, 0, 0),
|
||||
},
|
||||
},
|
||||
|
@ -138,7 +138,7 @@ pub fn eval_json_template(
|
||||
) -> Result<String, Error> {
|
||||
let Template { elements, .. } = template;
|
||||
{
|
||||
let mut value = String::from("");
|
||||
let mut value = String::new();
|
||||
for elem in elements {
|
||||
match eval_json_template_element(elem, variables) {
|
||||
Ok(v) => value.push_str(v.as_str()),
|
||||
@ -195,7 +195,7 @@ mod tests {
|
||||
},
|
||||
TemplateElement::Expression(Expr {
|
||||
space0: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 15, 1, 15),
|
||||
},
|
||||
variable: Variable {
|
||||
@ -203,7 +203,7 @@ mod tests {
|
||||
source_info: SourceInfo::new(1, 15, 1, 19),
|
||||
},
|
||||
space1: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 19, 1, 19),
|
||||
},
|
||||
}),
|
||||
@ -220,7 +220,7 @@ mod tests {
|
||||
JsonValue::Object {
|
||||
space0: "\n ".to_string(),
|
||||
elements: vec![JsonObjectElement {
|
||||
space0: "".to_string(),
|
||||
space0: String::new(),
|
||||
name: Template {
|
||||
delimiter: None,
|
||||
elements: vec![TemplateElement::String {
|
||||
@ -229,7 +229,7 @@ mod tests {
|
||||
}],
|
||||
source_info: SourceInfo::new(1, 1, 1, 1),
|
||||
},
|
||||
space1: "".to_string(),
|
||||
space1: String::new(),
|
||||
space2: " ".to_string(),
|
||||
value: JsonValue::String(Template {
|
||||
delimiter: None,
|
||||
@ -288,7 +288,7 @@ mod tests {
|
||||
assert_eq!(
|
||||
eval_json_value(
|
||||
&JsonValue::List {
|
||||
space0: "".to_string(),
|
||||
space0: String::new(),
|
||||
elements: vec![],
|
||||
},
|
||||
&variables,
|
||||
@ -301,22 +301,22 @@ mod tests {
|
||||
assert_eq!(
|
||||
eval_json_value(
|
||||
&JsonValue::List {
|
||||
space0: "".to_string(),
|
||||
space0: String::new(),
|
||||
elements: vec![
|
||||
JsonListElement {
|
||||
space0: "".to_string(),
|
||||
space0: String::new(),
|
||||
value: JsonValue::Number("1".to_string()),
|
||||
space1: "".to_string(),
|
||||
space1: String::new(),
|
||||
},
|
||||
JsonListElement {
|
||||
space0: " ".to_string(),
|
||||
value: JsonValue::Number("-2".to_string()),
|
||||
space1: "".to_string(),
|
||||
space1: String::new(),
|
||||
},
|
||||
JsonListElement {
|
||||
space0: " ".to_string(),
|
||||
value: JsonValue::Number("3.0".to_string()),
|
||||
space1: "".to_string(),
|
||||
space1: String::new(),
|
||||
},
|
||||
],
|
||||
},
|
||||
@ -338,17 +338,17 @@ mod tests {
|
||||
assert_eq!(
|
||||
eval_json_value(
|
||||
&JsonValue::List {
|
||||
space0: "".to_string(),
|
||||
space0: String::new(),
|
||||
elements: vec![
|
||||
JsonListElement {
|
||||
space0: "".to_string(),
|
||||
space0: String::new(),
|
||||
value: JsonValue::String(template),
|
||||
space1: "".to_string(),
|
||||
space1: String::new(),
|
||||
},
|
||||
JsonListElement {
|
||||
space0: " ".to_string(),
|
||||
value: json_hello_world_value(),
|
||||
space1: "".to_string(),
|
||||
space1: String::new(),
|
||||
},
|
||||
],
|
||||
},
|
||||
@ -366,7 +366,7 @@ mod tests {
|
||||
assert_eq!(
|
||||
eval_json_value(
|
||||
&JsonValue::Object {
|
||||
space0: "".to_string(),
|
||||
space0: String::new(),
|
||||
elements: vec![],
|
||||
},
|
||||
&variables,
|
||||
@ -455,7 +455,7 @@ mod tests {
|
||||
|
||||
fn whitespace() -> Whitespace {
|
||||
Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(0, 0, 0, 0),
|
||||
}
|
||||
}
|
||||
|
@ -126,10 +126,10 @@ mod tests {
|
||||
let graphql_variables = GraphQlVariables {
|
||||
space: whitespace(),
|
||||
value: JsonValue::Object {
|
||||
space0: "".to_string(),
|
||||
space0: String::new(),
|
||||
elements: vec![
|
||||
JsonObjectElement {
|
||||
space0: "".to_string(),
|
||||
space0: String::new(),
|
||||
name: Template {
|
||||
delimiter: Some('"'),
|
||||
elements: vec![TemplateElement::String {
|
||||
@ -138,8 +138,8 @@ mod tests {
|
||||
}],
|
||||
source_info: empty_source_info(),
|
||||
},
|
||||
space1: "".to_string(),
|
||||
space2: "".to_string(),
|
||||
space1: String::new(),
|
||||
space2: String::new(),
|
||||
value: JsonValue::String(Template {
|
||||
delimiter: Some('"'),
|
||||
elements: vec![TemplateElement::String {
|
||||
@ -148,10 +148,10 @@ mod tests {
|
||||
}],
|
||||
source_info: empty_source_info(),
|
||||
}),
|
||||
space3: "".to_string(),
|
||||
space3: String::new(),
|
||||
},
|
||||
JsonObjectElement {
|
||||
space0: "".to_string(),
|
||||
space0: String::new(),
|
||||
name: Template {
|
||||
delimiter: Some('"'),
|
||||
elements: vec![TemplateElement::String {
|
||||
@ -160,10 +160,10 @@ mod tests {
|
||||
}],
|
||||
source_info: empty_source_info(),
|
||||
},
|
||||
space1: "".to_string(),
|
||||
space2: "".to_string(),
|
||||
space1: String::new(),
|
||||
space2: String::new(),
|
||||
value: JsonValue::Boolean(false),
|
||||
space3: "".to_string(),
|
||||
space3: String::new(),
|
||||
},
|
||||
],
|
||||
},
|
||||
|
@ -1217,7 +1217,7 @@ mod tests {
|
||||
delimiter: Some('"'),
|
||||
elements: vec![TemplateElement::Expression(Expr {
|
||||
space0: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 11, 1, 11),
|
||||
},
|
||||
variable: Variable {
|
||||
@ -1225,7 +1225,7 @@ mod tests {
|
||||
source_info: SourceInfo::new(1, 11, 1, 19),
|
||||
},
|
||||
space1: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 19, 1, 19),
|
||||
},
|
||||
})],
|
||||
|
@ -453,7 +453,7 @@ pub mod tests {
|
||||
source_info: SourceInfo::new(1, 1, 1, 19),
|
||||
value: QueryValue::Jsonpath {
|
||||
space0: Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 9, 1, 10),
|
||||
},
|
||||
expr: Template {
|
||||
@ -474,7 +474,7 @@ pub mod tests {
|
||||
source_info: SourceInfo::new(1, 1, 1, 19),
|
||||
value: QueryValue::Jsonpath {
|
||||
space0: Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 9, 1, 10),
|
||||
},
|
||||
expr: Template {
|
||||
@ -495,7 +495,7 @@ pub mod tests {
|
||||
source_info: SourceInfo::new(1, 1, 1, 19),
|
||||
value: QueryValue::Jsonpath {
|
||||
space0: Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 9, 1, 10),
|
||||
},
|
||||
expr: Template {
|
||||
@ -516,7 +516,7 @@ pub mod tests {
|
||||
source_info: SourceInfo::new(1, 1, 1, 26),
|
||||
value: QueryValue::Regex {
|
||||
space0: Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 6, 1, 7),
|
||||
},
|
||||
value: RegexValue::Template(Template {
|
||||
@ -537,7 +537,7 @@ pub mod tests {
|
||||
source_info: SourceInfo::new(1, 1, 1, 26),
|
||||
value: QueryValue::Regex {
|
||||
space0: Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 6, 1, 7),
|
||||
},
|
||||
value: RegexValue::Template(Template {
|
||||
@ -633,7 +633,7 @@ pub mod tests {
|
||||
fn test_query_cookie() {
|
||||
let variables = HashMap::new();
|
||||
let space = Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(0, 0, 0, 0),
|
||||
};
|
||||
let response = http::Response {
|
||||
@ -982,7 +982,7 @@ pub mod tests {
|
||||
source_info: SourceInfo::new(0, 0, 0, 0),
|
||||
value: QueryValue::Jsonpath {
|
||||
space0: Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 9, 1, 10),
|
||||
},
|
||||
expr: Template {
|
||||
@ -1141,10 +1141,10 @@ pub mod tests {
|
||||
&http::Response {
|
||||
certificate: Some(http::Certificate {
|
||||
subject: "A=B, C=D".to_string(),
|
||||
issuer: "".to_string(),
|
||||
issuer: String::new(),
|
||||
start_date: Default::default(),
|
||||
expire_date: Default::default(),
|
||||
serial_number: "".to_string()
|
||||
serial_number: String::new()
|
||||
}),
|
||||
..Default::default()
|
||||
},
|
||||
|
@ -73,7 +73,7 @@ pub fn eval_asserts(
|
||||
Err(e) => {
|
||||
asserts.push(AssertResult::Header {
|
||||
actual: Err(e),
|
||||
expected: String::from(""),
|
||||
expected: String::new(),
|
||||
source_info: header.key.clone().source_info,
|
||||
});
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ pub fn eval_template(
|
||||
variables: &HashMap<String, Value>,
|
||||
) -> Result<String, Error> {
|
||||
let Template { elements, .. } = template;
|
||||
let mut value = String::from("");
|
||||
let mut value = String::new();
|
||||
for elem in elements {
|
||||
match eval_template_element(elem, variables) {
|
||||
Ok(v) => value.push_str(v.as_str()),
|
||||
@ -93,7 +93,7 @@ mod tests {
|
||||
// {{name}}
|
||||
TemplateElement::Expression(Expr {
|
||||
space0: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 3, 1, 3),
|
||||
},
|
||||
variable: Variable {
|
||||
@ -101,7 +101,7 @@ mod tests {
|
||||
source_info: SourceInfo::new(1, 3, 1, 7),
|
||||
},
|
||||
space1: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 7, 1, 7),
|
||||
},
|
||||
})
|
||||
|
@ -192,7 +192,7 @@ impl Default for LoggerOptionsBuilder {
|
||||
LoggerOptionsBuilder {
|
||||
color: false,
|
||||
error_format: ErrorFormat::Short,
|
||||
filename: "".to_string(),
|
||||
filename: String::new(),
|
||||
progress_bar: false,
|
||||
test: false,
|
||||
verbosity: None,
|
||||
@ -518,7 +518,7 @@ fn progress_string(entry_index: usize, count: usize) -> String {
|
||||
let completed = if col > 0 {
|
||||
"=".repeat(col)
|
||||
} else {
|
||||
"".to_string()
|
||||
String::new()
|
||||
};
|
||||
let void = " ".repeat(WIDTH - col - 1);
|
||||
format!("[{completed}>{void}] {entry_index}/{count}")
|
||||
|
@ -61,7 +61,7 @@ impl fmt::Display for StatusValue {
|
||||
|
||||
impl fmt::Display for Template {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
let mut buffer = String::from("");
|
||||
let mut buffer = String::new();
|
||||
for element in self.elements.iter() {
|
||||
buffer.push_str(element.to_string().as_str());
|
||||
}
|
||||
@ -143,7 +143,7 @@ impl fmt::Display for MultilineString {
|
||||
| MultilineString::Xml(text) => text.value.to_string(),
|
||||
MultilineString::GraphQl(graphql) => {
|
||||
let var = match &graphql.variables {
|
||||
None => "".to_string(),
|
||||
None => String::new(),
|
||||
Some(var) => {
|
||||
format!(
|
||||
"variables{}{}{}",
|
||||
@ -256,7 +256,7 @@ mod tests {
|
||||
|
||||
fn whitespace() -> Whitespace {
|
||||
Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(0, 0, 0, 0),
|
||||
}
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ impl fmt::Display for Value {
|
||||
|
||||
impl fmt::Display for ListElement {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
let mut s = "".to_string();
|
||||
let mut s = String::new();
|
||||
s.push_str(self.space0.as_str());
|
||||
s.push_str(self.value.to_string().as_str());
|
||||
s.push_str(self.space1.as_str());
|
||||
@ -119,7 +119,7 @@ impl fmt::Display for ListElement {
|
||||
|
||||
impl fmt::Display for ObjectElement {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
let mut s = "".to_string();
|
||||
let mut s = String::new();
|
||||
s.push_str(self.space0.as_str());
|
||||
s.push('"');
|
||||
s.push_str(self.name.to_string().as_str());
|
||||
@ -167,7 +167,7 @@ impl Value {
|
||||
|
||||
impl ListElement {
|
||||
fn encoded(&self) -> String {
|
||||
let mut s = "".to_string();
|
||||
let mut s = String::new();
|
||||
s.push_str(self.space0.as_str());
|
||||
s.push_str(self.value.encoded().as_str());
|
||||
s.push_str(self.space1.as_str());
|
||||
@ -177,7 +177,7 @@ impl ListElement {
|
||||
|
||||
impl ObjectElement {
|
||||
fn encoded(&self) -> String {
|
||||
let mut s = "".to_string();
|
||||
let mut s = String::new();
|
||||
s.push_str(self.space0.as_str());
|
||||
s.push_str(self.name.encoded().as_str());
|
||||
s.push_str(self.space1.as_str());
|
||||
@ -191,7 +191,7 @@ impl ObjectElement {
|
||||
|
||||
impl Template {
|
||||
fn encoded(&self) -> String {
|
||||
let mut s = "".to_string();
|
||||
let mut s = String::new();
|
||||
if let Some(d) = self.delimiter {
|
||||
s.push(d)
|
||||
}
|
||||
@ -224,7 +224,7 @@ mod tests {
|
||||
"{{x}}".to_string(),
|
||||
Value::Expression(Expr {
|
||||
space0: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(0, 0, 0, 0),
|
||||
},
|
||||
variable: Variable {
|
||||
@ -232,7 +232,7 @@ mod tests {
|
||||
source_info: SourceInfo::new(0, 0, 0, 0),
|
||||
},
|
||||
space1: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(0, 0, 0, 0),
|
||||
},
|
||||
})
|
||||
@ -255,7 +255,7 @@ mod tests {
|
||||
assert_eq!(
|
||||
"[]".to_string(),
|
||||
Value::List {
|
||||
space0: "".to_string(),
|
||||
space0: String::new(),
|
||||
elements: vec![],
|
||||
}
|
||||
.to_string()
|
||||
@ -263,22 +263,22 @@ mod tests {
|
||||
assert_eq!(
|
||||
"[1, 2, 3]".to_string(),
|
||||
Value::List {
|
||||
space0: "".to_string(),
|
||||
space0: String::new(),
|
||||
elements: vec![
|
||||
ListElement {
|
||||
space0: "".to_string(),
|
||||
space0: String::new(),
|
||||
value: Value::Number("1".to_string()),
|
||||
space1: "".to_string(),
|
||||
space1: String::new(),
|
||||
},
|
||||
ListElement {
|
||||
space0: " ".to_string(),
|
||||
value: Value::Number("2".to_string()),
|
||||
space1: "".to_string(),
|
||||
space1: String::new(),
|
||||
},
|
||||
ListElement {
|
||||
space0: " ".to_string(),
|
||||
value: Value::Number("3".to_string()),
|
||||
space1: "".to_string(),
|
||||
space1: String::new(),
|
||||
}
|
||||
],
|
||||
}
|
||||
@ -287,7 +287,7 @@ mod tests {
|
||||
assert_eq!(
|
||||
"{}".to_string(),
|
||||
Value::Object {
|
||||
space0: "".to_string(),
|
||||
space0: String::new(),
|
||||
elements: vec![],
|
||||
}
|
||||
.to_string()
|
||||
@ -295,7 +295,7 @@ mod tests {
|
||||
assert_eq!(
|
||||
"{ \"id\": 123 }".to_string(),
|
||||
Value::Object {
|
||||
space0: "".to_string(),
|
||||
space0: String::new(),
|
||||
elements: vec![ObjectElement {
|
||||
space0: " ".to_string(),
|
||||
name: Template {
|
||||
@ -306,7 +306,7 @@ mod tests {
|
||||
}],
|
||||
source_info: SourceInfo::new(1, 1, 1, 1),
|
||||
},
|
||||
space1: "".to_string(),
|
||||
space1: String::new(),
|
||||
space2: " ".to_string(),
|
||||
value: Value::Number("123".to_string()),
|
||||
space3: " ".to_string(),
|
||||
@ -322,7 +322,7 @@ mod tests {
|
||||
assert_eq!(
|
||||
TemplateElement::Expression(Expr {
|
||||
space0: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 1, 1, 1),
|
||||
},
|
||||
variable: Variable {
|
||||
@ -330,7 +330,7 @@ mod tests {
|
||||
source_info: SourceInfo::new(1, 1, 1, 1),
|
||||
},
|
||||
space1: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 1, 1, 1),
|
||||
},
|
||||
})
|
||||
@ -342,7 +342,7 @@ mod tests {
|
||||
delimiter: None,
|
||||
elements: vec![TemplateElement::Expression(Expr {
|
||||
space0: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 1, 1, 1),
|
||||
},
|
||||
variable: Variable {
|
||||
@ -350,7 +350,7 @@ mod tests {
|
||||
source_info: SourceInfo::new(1, 1, 1, 1),
|
||||
},
|
||||
space1: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 1, 1, 1),
|
||||
},
|
||||
})],
|
||||
|
@ -815,7 +815,7 @@ fn escape_xml(s: &str) -> String {
|
||||
|
||||
impl Template {
|
||||
fn to_encoded_string(&self) -> String {
|
||||
let mut s = "".to_string();
|
||||
let mut s = String::new();
|
||||
if let Some(d) = self.delimiter {
|
||||
s.push(d);
|
||||
}
|
||||
@ -863,7 +863,7 @@ mod tests {
|
||||
let multiline_string = MultilineString::OneLineText(Template {
|
||||
delimiter: None,
|
||||
elements: vec![TemplateElement::String {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
encoded: "unused".to_string(),
|
||||
}],
|
||||
source_info: SourceInfo::new(0, 0, 0, 0),
|
||||
@ -906,7 +906,7 @@ mod tests {
|
||||
// ```
|
||||
let multiline_string = MultilineString::Text(Text {
|
||||
space: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo {
|
||||
start: Pos { line: 1, column: 4 },
|
||||
end: Pos { line: 1, column: 4 },
|
||||
@ -981,7 +981,7 @@ mod tests {
|
||||
fn test_json() {
|
||||
let mut fmt = HtmlFormatter::new();
|
||||
let value = JsonValue::Object {
|
||||
space0: "".to_string(),
|
||||
space0: String::new(),
|
||||
elements: vec![JsonObjectElement {
|
||||
space0: "\n ".to_string(),
|
||||
name: Template {
|
||||
@ -992,7 +992,7 @@ mod tests {
|
||||
}],
|
||||
source_info: SourceInfo::new(0, 0, 0, 0),
|
||||
},
|
||||
space1: "".to_string(),
|
||||
space1: String::new(),
|
||||
space2: " ".to_string(),
|
||||
value: JsonValue::Number("1".to_string()),
|
||||
space3: "\n".to_string(),
|
||||
|
@ -140,7 +140,7 @@ fn value(c: char) -> Option<i32> {
|
||||
|
||||
fn padding(reader: &mut Reader) -> String {
|
||||
// consume padding can not fail
|
||||
let mut buf = String::from("");
|
||||
let mut buf = String::new();
|
||||
loop {
|
||||
let save = reader.state.clone();
|
||||
match reader.read() {
|
||||
|
@ -84,22 +84,22 @@ mod tests {
|
||||
assert_eq!(
|
||||
bytes(&mut reader).unwrap(),
|
||||
Bytes::Json(JsonValue::List {
|
||||
space0: "".to_string(),
|
||||
space0: String::new(),
|
||||
elements: vec![
|
||||
JsonListElement {
|
||||
space0: "".to_string(),
|
||||
space0: String::new(),
|
||||
value: JsonValue::Number("1".to_string()),
|
||||
space1: "".to_string(),
|
||||
space1: String::new(),
|
||||
},
|
||||
JsonListElement {
|
||||
space0: "".to_string(),
|
||||
space0: String::new(),
|
||||
value: JsonValue::Number("2".to_string()),
|
||||
space1: "".to_string(),
|
||||
space1: String::new(),
|
||||
},
|
||||
JsonListElement {
|
||||
space0: "".to_string(),
|
||||
space0: String::new(),
|
||||
value: JsonValue::Number("3".to_string()),
|
||||
space1: "".to_string(),
|
||||
space1: String::new(),
|
||||
},
|
||||
],
|
||||
})
|
||||
|
@ -107,12 +107,12 @@ mod tests {
|
||||
},
|
||||
attribute: Some(CookieAttribute {
|
||||
space0: Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 9, 1, 9),
|
||||
},
|
||||
name: CookieAttributeName::Domain("Domain".to_string()),
|
||||
space1: Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 15, 1, 15),
|
||||
},
|
||||
}),
|
||||
@ -131,7 +131,7 @@ mod tests {
|
||||
delimiter: None,
|
||||
elements: vec![TemplateElement::Expression(Expr {
|
||||
space0: Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 3, 1, 3),
|
||||
},
|
||||
variable: Variable {
|
||||
@ -139,7 +139,7 @@ mod tests {
|
||||
source_info: SourceInfo::new(1, 3, 1, 7),
|
||||
},
|
||||
space1: Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 7, 1, 7),
|
||||
},
|
||||
})],
|
||||
@ -147,12 +147,12 @@ mod tests {
|
||||
},
|
||||
attribute: Some(CookieAttribute {
|
||||
space0: Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 10, 1, 10),
|
||||
},
|
||||
name: CookieAttributeName::Domain("Domain".to_string()),
|
||||
space1: Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 16, 1, 16),
|
||||
},
|
||||
}),
|
||||
|
@ -96,7 +96,7 @@ mod tests {
|
||||
source_info: SourceInfo::new(1, 4, 1, 8),
|
||||
},
|
||||
space1: Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 8, 1, 8),
|
||||
},
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ pub fn number_value(reader: &mut Reader) -> ParseResult<'static, JsonValue> {
|
||||
let start = reader.state.clone();
|
||||
|
||||
let sign = match try_literal("-", reader) {
|
||||
Err(_) => "".to_string(),
|
||||
Err(_) => String::new(),
|
||||
Ok(_) => "-".to_string(),
|
||||
};
|
||||
|
||||
@ -206,7 +206,7 @@ pub fn number_value(reader: &mut Reader) -> ParseResult<'static, JsonValue> {
|
||||
format!(".{digits}")
|
||||
}
|
||||
}
|
||||
Err(_) => "".to_string(),
|
||||
Err(_) => String::new(),
|
||||
};
|
||||
|
||||
let exponent = if reader.peek() == Some('e') || reader.peek() == Some('E') {
|
||||
@ -215,13 +215,13 @@ pub fn number_value(reader: &mut Reader) -> ParseResult<'static, JsonValue> {
|
||||
Ok(_) => "-".to_string(),
|
||||
Err(_) => match try_literal("+", reader) {
|
||||
Ok(_) => "+".to_string(),
|
||||
Err(_) => "".to_string(),
|
||||
Err(_) => String::new(),
|
||||
},
|
||||
};
|
||||
let exponent_digits = reader.read_while(|c| c.is_ascii_digit());
|
||||
format!("e{exponent_sign}{exponent_digits}")
|
||||
} else {
|
||||
"".to_string()
|
||||
String::new()
|
||||
};
|
||||
|
||||
Ok(JsonValue::Number(format!(
|
||||
@ -427,7 +427,7 @@ mod tests {
|
||||
},
|
||||
TemplateElement::Expression(Expr {
|
||||
space0: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 15, 1, 15),
|
||||
},
|
||||
variable: Variable {
|
||||
@ -435,7 +435,7 @@ mod tests {
|
||||
source_info: SourceInfo::new(1, 15, 1, 19),
|
||||
},
|
||||
space1: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 19, 1, 19),
|
||||
},
|
||||
}),
|
||||
@ -693,7 +693,7 @@ mod tests {
|
||||
expression_value(&mut reader).unwrap(),
|
||||
JsonValue::Expression(Expr {
|
||||
space0: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 3, 1, 3)
|
||||
},
|
||||
variable: Variable {
|
||||
@ -701,7 +701,7 @@ mod tests {
|
||||
source_info: SourceInfo::new(1, 3, 1, 4)
|
||||
},
|
||||
space1: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 4, 1, 4)
|
||||
}
|
||||
})
|
||||
@ -715,7 +715,7 @@ mod tests {
|
||||
assert_eq!(
|
||||
list_value(&mut reader).unwrap(),
|
||||
JsonValue::List {
|
||||
space0: "".to_string(),
|
||||
space0: String::new(),
|
||||
elements: vec![]
|
||||
}
|
||||
);
|
||||
@ -735,11 +735,11 @@ mod tests {
|
||||
assert_eq!(
|
||||
list_value(&mut reader).unwrap(),
|
||||
JsonValue::List {
|
||||
space0: "".to_string(),
|
||||
space0: String::new(),
|
||||
elements: vec![JsonListElement {
|
||||
space0: "".to_string(),
|
||||
space0: String::new(),
|
||||
value: JsonValue::Boolean(true),
|
||||
space1: "".to_string(),
|
||||
space1: String::new(),
|
||||
}],
|
||||
}
|
||||
);
|
||||
@ -772,9 +772,9 @@ mod tests {
|
||||
assert_eq!(
|
||||
list_element(&mut reader).unwrap(),
|
||||
JsonListElement {
|
||||
space0: "".to_string(),
|
||||
space0: String::new(),
|
||||
value: JsonValue::Boolean(true),
|
||||
space1: "".to_string(),
|
||||
space1: String::new(),
|
||||
}
|
||||
);
|
||||
assert_eq!(reader.state.cursor, 4);
|
||||
@ -786,7 +786,7 @@ mod tests {
|
||||
assert_eq!(
|
||||
object_value(&mut reader).unwrap(),
|
||||
JsonValue::Object {
|
||||
space0: "".to_string(),
|
||||
space0: String::new(),
|
||||
elements: vec![]
|
||||
}
|
||||
);
|
||||
@ -808,7 +808,7 @@ mod tests {
|
||||
JsonValue::Object {
|
||||
space0: "\n ".to_string(),
|
||||
elements: vec![JsonObjectElement {
|
||||
space0: "".to_string(),
|
||||
space0: String::new(),
|
||||
name: Template {
|
||||
delimiter: Some('"'),
|
||||
elements: vec![TemplateElement::String {
|
||||
@ -817,7 +817,7 @@ mod tests {
|
||||
}],
|
||||
source_info: SourceInfo::new(2, 4, 2, 5)
|
||||
},
|
||||
space1: "".to_string(),
|
||||
space1: String::new(),
|
||||
space2: " ".to_string(),
|
||||
value: JsonValue::Boolean(true),
|
||||
space3: "\n".to_string(),
|
||||
@ -853,7 +853,7 @@ mod tests {
|
||||
assert_eq!(
|
||||
object_element(&mut reader).unwrap(),
|
||||
JsonObjectElement {
|
||||
space0: "".to_string(),
|
||||
space0: String::new(),
|
||||
name: Template {
|
||||
delimiter: Some('"'),
|
||||
elements: vec![TemplateElement::String {
|
||||
@ -862,10 +862,10 @@ mod tests {
|
||||
}],
|
||||
source_info: SourceInfo::new(1, 2, 1, 3)
|
||||
},
|
||||
space1: "".to_string(),
|
||||
space1: String::new(),
|
||||
space2: " ".to_string(),
|
||||
value: JsonValue::Boolean(true),
|
||||
space3: "".to_string(),
|
||||
space3: String::new(),
|
||||
}
|
||||
);
|
||||
assert_eq!(reader.state.cursor, 9);
|
||||
@ -894,7 +894,7 @@ mod tests {
|
||||
#[test]
|
||||
fn test_whitespace() {
|
||||
let mut reader = Reader::new("");
|
||||
assert_eq!(whitespace(&mut reader), "".to_string());
|
||||
assert_eq!(whitespace(&mut reader), String::new());
|
||||
assert_eq!(reader.state.cursor, 0);
|
||||
|
||||
let mut reader = Reader::new(" x");
|
||||
|
@ -305,7 +305,7 @@ mod tests {
|
||||
multiline_string(&mut reader).unwrap(),
|
||||
MultilineString::Text(Text {
|
||||
space: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 4, 1, 4),
|
||||
},
|
||||
newline: Whitespace {
|
||||
@ -354,7 +354,7 @@ mod tests {
|
||||
multiline_string(&mut reader).unwrap(),
|
||||
MultilineString::Json(Text {
|
||||
space: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 8, 1, 8),
|
||||
},
|
||||
newline: Whitespace {
|
||||
@ -380,7 +380,7 @@ mod tests {
|
||||
multiline_string(&mut reader).unwrap(),
|
||||
MultilineString::GraphQl(GraphQl {
|
||||
space: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 11, 1, 11),
|
||||
},
|
||||
newline: Whitespace {
|
||||
@ -454,7 +454,7 @@ mod tests {
|
||||
multiline_string(&mut reader).unwrap(),
|
||||
MultilineString::Text(Text {
|
||||
space: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 4, 1, 4),
|
||||
},
|
||||
newline: Whitespace {
|
||||
@ -473,7 +473,7 @@ mod tests {
|
||||
multiline_string(&mut reader).unwrap(),
|
||||
MultilineString::Text(Text {
|
||||
space: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 4, 1, 4),
|
||||
},
|
||||
newline: Whitespace {
|
||||
@ -528,7 +528,7 @@ mod tests {
|
||||
multiline_string(&mut reader).unwrap(),
|
||||
MultilineString::Text(Text {
|
||||
space: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 4, 1, 4),
|
||||
},
|
||||
newline: Whitespace {
|
||||
@ -554,7 +554,7 @@ mod tests {
|
||||
multiline_string(&mut reader).unwrap(),
|
||||
MultilineString::Text(Text {
|
||||
space: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 4, 1, 4),
|
||||
},
|
||||
newline: Whitespace {
|
||||
@ -578,7 +578,7 @@ mod tests {
|
||||
multiline_string(&mut reader).unwrap(),
|
||||
MultilineString::Text(Text {
|
||||
space: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 4, 1, 4),
|
||||
},
|
||||
newline: Whitespace {
|
||||
@ -676,7 +676,7 @@ variables {
|
||||
multiline_string(&mut reader).unwrap(),
|
||||
MultilineString::GraphQl(GraphQl {
|
||||
space: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 11, 1, 11),
|
||||
},
|
||||
newline: Whitespace {
|
||||
@ -700,7 +700,7 @@ variables {
|
||||
value: JsonValue::Object {
|
||||
space0: "\n ".to_string(),
|
||||
elements: vec![JsonObjectElement {
|
||||
space0: "".to_string(),
|
||||
space0: String::new(),
|
||||
name: Template {
|
||||
delimiter: Some('"'),
|
||||
elements: vec![
|
||||
@ -711,7 +711,7 @@ variables {
|
||||
],
|
||||
source_info: SourceInfo::new(9, 4, 9, 8)
|
||||
},
|
||||
space1: "".to_string(),
|
||||
space1: String::new(),
|
||||
space2: " ".to_string(),
|
||||
value: JsonValue::String(Template {
|
||||
delimiter: Some('"'),
|
||||
|
@ -291,7 +291,7 @@ mod tests {
|
||||
let default_request = Request {
|
||||
line_terminators: vec![],
|
||||
space0: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 1, 1, 1),
|
||||
},
|
||||
method: Method("GET".to_string()),
|
||||
@ -309,12 +309,12 @@ mod tests {
|
||||
},
|
||||
line_terminator0: LineTerminator {
|
||||
space0: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 21, 1, 21),
|
||||
},
|
||||
comment: None,
|
||||
newline: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 21, 1, 21),
|
||||
},
|
||||
},
|
||||
@ -329,7 +329,7 @@ mod tests {
|
||||
let default_request = Request {
|
||||
line_terminators: vec![],
|
||||
space0: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 1, 1, 1),
|
||||
},
|
||||
method: Method("GET".to_string()),
|
||||
@ -354,7 +354,7 @@ mod tests {
|
||||
value: " comment".to_string(),
|
||||
}),
|
||||
newline: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 32, 1, 32),
|
||||
},
|
||||
},
|
||||
@ -386,12 +386,12 @@ mod tests {
|
||||
Body {
|
||||
line_terminators: vec![],
|
||||
space0: Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(2, 1, 2, 1),
|
||||
},
|
||||
value: Bytes::MultilineString(MultilineString::Text(Text {
|
||||
space: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(2, 4, 2, 4),
|
||||
},
|
||||
newline: Whitespace {
|
||||
@ -409,12 +409,12 @@ mod tests {
|
||||
})),
|
||||
line_terminator0: LineTerminator {
|
||||
space0: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(4, 4, 4, 4),
|
||||
},
|
||||
comment: None,
|
||||
newline: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(4, 4, 4, 4),
|
||||
},
|
||||
},
|
||||
@ -430,22 +430,22 @@ mod tests {
|
||||
assert_eq!(
|
||||
r.body.unwrap().value,
|
||||
Bytes::Json(JsonValue::List {
|
||||
space0: "".to_string(),
|
||||
space0: String::new(),
|
||||
elements: vec![
|
||||
JsonListElement {
|
||||
space0: "".to_string(),
|
||||
space0: String::new(),
|
||||
value: JsonValue::Number("1".to_string()),
|
||||
space1: "".to_string(),
|
||||
space1: String::new(),
|
||||
},
|
||||
JsonListElement {
|
||||
space0: "".to_string(),
|
||||
space0: String::new(),
|
||||
value: JsonValue::Number("2".to_string()),
|
||||
space1: "".to_string(),
|
||||
space1: String::new(),
|
||||
},
|
||||
JsonListElement {
|
||||
space0: "".to_string(),
|
||||
space0: String::new(),
|
||||
value: JsonValue::Number("3".to_string()),
|
||||
space1: "".to_string(),
|
||||
space1: String::new(),
|
||||
},
|
||||
],
|
||||
})
|
||||
@ -546,22 +546,22 @@ mod tests {
|
||||
assert_eq!(
|
||||
b.value,
|
||||
Bytes::Json(JsonValue::List {
|
||||
space0: "".to_string(),
|
||||
space0: String::new(),
|
||||
elements: vec![
|
||||
JsonListElement {
|
||||
space0: "".to_string(),
|
||||
space0: String::new(),
|
||||
value: JsonValue::Number("1".to_string()),
|
||||
space1: "".to_string(),
|
||||
space1: String::new(),
|
||||
},
|
||||
JsonListElement {
|
||||
space0: "".to_string(),
|
||||
space0: String::new(),
|
||||
value: JsonValue::Number("2".to_string()),
|
||||
space1: "".to_string(),
|
||||
space1: String::new(),
|
||||
},
|
||||
JsonListElement {
|
||||
space0: "".to_string(),
|
||||
space0: String::new(),
|
||||
value: JsonValue::Number("3".to_string()),
|
||||
space1: "".to_string(),
|
||||
space1: String::new(),
|
||||
},
|
||||
],
|
||||
})
|
||||
@ -574,7 +574,7 @@ mod tests {
|
||||
assert_eq!(
|
||||
b.value,
|
||||
Bytes::Json(JsonValue::Object {
|
||||
space0: "".to_string(),
|
||||
space0: String::new(),
|
||||
elements: vec![],
|
||||
})
|
||||
);
|
||||
@ -586,7 +586,7 @@ mod tests {
|
||||
assert_eq!(
|
||||
b.value,
|
||||
Bytes::Json(JsonValue::Object {
|
||||
space0: "".to_string(),
|
||||
space0: String::new(),
|
||||
elements: vec![],
|
||||
})
|
||||
);
|
||||
|
@ -37,7 +37,7 @@ pub fn predicate(reader: &mut Reader) -> ParseResult<'static, Predicate> {
|
||||
fn predicate_not(reader: &mut Reader) -> (bool, Whitespace) {
|
||||
let save = reader.state.clone();
|
||||
let no_whitespace = Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo {
|
||||
start: save.pos.clone(),
|
||||
end: save.pos.clone(),
|
||||
@ -384,7 +384,7 @@ mod tests {
|
||||
(
|
||||
false,
|
||||
Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 1, 1, 1),
|
||||
}
|
||||
)
|
||||
@ -527,7 +527,7 @@ mod tests {
|
||||
PredicateFuncValue::Equal {
|
||||
value: PredicateValue::Expression(Expr {
|
||||
space0: Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 10, 1, 10),
|
||||
},
|
||||
variable: Variable {
|
||||
@ -535,7 +535,7 @@ mod tests {
|
||||
source_info: SourceInfo::new(1, 10, 1, 15),
|
||||
},
|
||||
space1: Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 15, 1, 15),
|
||||
},
|
||||
}),
|
||||
|
@ -97,7 +97,7 @@ pub fn line_terminator(reader: &mut Reader) -> ParseResult<'static, LineTerminat
|
||||
let comment = optional(comment, reader)?;
|
||||
let nl = if reader.is_eof() {
|
||||
Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(
|
||||
reader.state.pos.line,
|
||||
reader.state.pos.column,
|
||||
@ -133,7 +133,7 @@ pub fn optional_line_terminators(reader: &mut Reader) -> ParseResult<'static, Ve
|
||||
|
||||
pub fn comment(reader: &mut Reader) -> ParseResult<'static, Comment> {
|
||||
try_literal("#", reader)?;
|
||||
let mut value = "".to_string();
|
||||
let mut value = String::new();
|
||||
loop {
|
||||
if reader.is_eof() {
|
||||
break;
|
||||
@ -331,7 +331,7 @@ pub fn hex(reader: &mut Reader) -> ParseResult<'static, Hex> {
|
||||
pub fn regex(reader: &mut Reader) -> ParseResult<'static, Regex> {
|
||||
try_literal("/", reader)?;
|
||||
let start = reader.state.pos.clone();
|
||||
let mut s = String::from("");
|
||||
let mut s = String::new();
|
||||
|
||||
// Hurl escaping /
|
||||
// in order to avoid terminating the regex
|
||||
@ -645,7 +645,7 @@ mod tests {
|
||||
assert_eq!(
|
||||
zero_or_more_spaces(&mut reader),
|
||||
Ok(Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 1, 1, 1),
|
||||
})
|
||||
);
|
||||
@ -677,7 +677,7 @@ mod tests {
|
||||
assert_eq!(
|
||||
comment(&mut reader),
|
||||
Ok(Comment {
|
||||
value: "".to_string()
|
||||
value: String::new()
|
||||
})
|
||||
);
|
||||
|
||||
@ -756,7 +756,7 @@ mod tests {
|
||||
KeyValue {
|
||||
line_terminators: vec![],
|
||||
space0: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 1, 1, 1),
|
||||
},
|
||||
key: EncodedString {
|
||||
@ -766,7 +766,7 @@ mod tests {
|
||||
source_info: SourceInfo::new(1, 1, 1, 8),
|
||||
},
|
||||
space1: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 8, 1, 8),
|
||||
},
|
||||
space2: Whitespace {
|
||||
@ -782,7 +782,7 @@ mod tests {
|
||||
},
|
||||
TemplateElement::Expression(Expr {
|
||||
space0: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 18, 1, 18),
|
||||
},
|
||||
variable: Variable {
|
||||
@ -790,7 +790,7 @@ mod tests {
|
||||
source_info: SourceInfo::new(1, 18, 1, 22),
|
||||
},
|
||||
space1: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 22, 1, 22),
|
||||
},
|
||||
}),
|
||||
@ -810,7 +810,7 @@ mod tests {
|
||||
value: " comment".to_string()
|
||||
}),
|
||||
newline: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 35, 1, 35),
|
||||
},
|
||||
},
|
||||
@ -1086,7 +1086,7 @@ mod tests {
|
||||
value: vec![255],
|
||||
encoded: "ff".to_string(),
|
||||
space1: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 8, 1, 8),
|
||||
},
|
||||
}
|
||||
@ -1097,7 +1097,7 @@ mod tests {
|
||||
hex(&mut reader).unwrap(),
|
||||
Hex {
|
||||
space0: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 5, 1, 5),
|
||||
},
|
||||
value: vec![1, 2, 3],
|
||||
@ -1185,7 +1185,7 @@ mod tests {
|
||||
file(&mut reader).unwrap(),
|
||||
File {
|
||||
space0: Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 6, 1, 6),
|
||||
},
|
||||
filename: Filename {
|
||||
@ -1193,7 +1193,7 @@ mod tests {
|
||||
source_info: SourceInfo::new(1, 6, 1, 14),
|
||||
},
|
||||
space1: Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 14, 1, 14),
|
||||
},
|
||||
}
|
||||
@ -1212,7 +1212,7 @@ mod tests {
|
||||
source_info: SourceInfo::new(1, 7, 1, 16),
|
||||
},
|
||||
space1: Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 16, 1, 16),
|
||||
},
|
||||
}
|
||||
@ -1231,7 +1231,7 @@ mod tests {
|
||||
source_info: SourceInfo::new(1, 7, 1, 20),
|
||||
},
|
||||
space1: Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 20, 1, 20),
|
||||
},
|
||||
}
|
||||
@ -1250,7 +1250,7 @@ mod tests {
|
||||
source_info: SourceInfo::new(1, 7, 1, 37),
|
||||
},
|
||||
space1: Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 37, 1, 37),
|
||||
},
|
||||
}
|
||||
@ -1312,7 +1312,7 @@ mod tests {
|
||||
value: vec![77, 97],
|
||||
encoded: String::from("T WE="),
|
||||
space1: Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 15, 1, 15),
|
||||
},
|
||||
}
|
||||
|
@ -287,12 +287,12 @@ mod tests {
|
||||
},
|
||||
attribute: Some(CookieAttribute {
|
||||
space0: Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 13, 1, 13),
|
||||
},
|
||||
name: CookieAttributeName::Domain("Domain".to_string()),
|
||||
space1: Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 19, 1, 19),
|
||||
},
|
||||
}),
|
||||
|
@ -87,7 +87,7 @@ impl Reader {
|
||||
/// Returns `count` chars from the buffer advancing the internal state.
|
||||
/// This methods can returns less than `count` chars if there is not enough chars in the buffer.
|
||||
pub fn read_n(&mut self, count: usize) -> String {
|
||||
let mut s = String::from("");
|
||||
let mut s = String::new();
|
||||
for _ in 0..count {
|
||||
match self.read() {
|
||||
None => {}
|
||||
@ -99,7 +99,7 @@ impl Reader {
|
||||
|
||||
/// Returns chars from the buffer while `predicate` is true, advancing the internal state.
|
||||
pub fn read_while(&mut self, predicate: fn(&char) -> bool) -> String {
|
||||
let mut s = String::from("");
|
||||
let mut s = String::new();
|
||||
loop {
|
||||
match self.peek() {
|
||||
None => return s,
|
||||
@ -116,7 +116,7 @@ impl Reader {
|
||||
|
||||
// only support escaped spaces for now
|
||||
pub fn read_while_escaping(&mut self, predicate: fn(&char) -> bool) -> String {
|
||||
let mut s = String::from("");
|
||||
let mut s = String::new();
|
||||
let mut escaped = false;
|
||||
loop {
|
||||
match self.peek() {
|
||||
|
@ -234,7 +234,7 @@ fn file_value(reader: &mut Reader) -> ParseResult<'static, FileValue> {
|
||||
Ok(_) => {
|
||||
reader.state = save.clone();
|
||||
let space2 = Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo {
|
||||
start: save.pos.clone(),
|
||||
end: save.pos,
|
||||
@ -261,13 +261,13 @@ fn file_value(reader: &mut Reader) -> ParseResult<'static, FileValue> {
|
||||
|
||||
fn file_content_type(reader: &mut Reader) -> ParseResult<'static, String> {
|
||||
let start = reader.state.clone();
|
||||
let mut buf = "".to_string();
|
||||
let mut spaces = "".to_string();
|
||||
let mut buf = String::new();
|
||||
let mut spaces = String::new();
|
||||
let mut save = reader.state.clone();
|
||||
while let Some(c) = reader.read() {
|
||||
if c.is_alphanumeric() || c == '/' || c == ';' || c == '=' || c == '-' {
|
||||
buf.push_str(spaces.as_str());
|
||||
spaces = "".to_string();
|
||||
spaces = String::new();
|
||||
buf.push(c);
|
||||
save = reader.state.clone();
|
||||
} else if c == ' ' {
|
||||
@ -656,12 +656,12 @@ mod tests {
|
||||
Section {
|
||||
line_terminators: vec![],
|
||||
space0: Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 1, 1, 1),
|
||||
},
|
||||
line_terminator0: LineTerminator {
|
||||
space0: Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 10, 1, 10),
|
||||
},
|
||||
comment: None,
|
||||
@ -673,7 +673,7 @@ mod tests {
|
||||
value: SectionValue::Asserts(vec![Assert {
|
||||
line_terminators: vec![],
|
||||
space0: Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(2, 1, 2, 1),
|
||||
},
|
||||
query: Query {
|
||||
@ -701,7 +701,7 @@ mod tests {
|
||||
predicate: Predicate {
|
||||
not: false,
|
||||
space0: Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(2, 19, 2, 19),
|
||||
},
|
||||
predicate_func: PredicateFunc {
|
||||
@ -725,7 +725,7 @@ mod tests {
|
||||
},
|
||||
line_terminator0: LineTerminator {
|
||||
space0: Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(2, 45, 2, 45),
|
||||
},
|
||||
comment: None,
|
||||
@ -792,14 +792,14 @@ mod tests {
|
||||
EntryOption {
|
||||
line_terminators: vec![],
|
||||
space0: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo {
|
||||
start: Pos { line: 1, column: 1 },
|
||||
end: Pos { line: 1, column: 1 },
|
||||
},
|
||||
},
|
||||
space1: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo {
|
||||
start: Pos { line: 1, column: 9 },
|
||||
end: Pos { line: 1, column: 9 },
|
||||
@ -821,7 +821,7 @@ mod tests {
|
||||
kind: OptionKind::Insecure(true),
|
||||
line_terminator0: LineTerminator {
|
||||
space0: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo {
|
||||
start: Pos {
|
||||
line: 1,
|
||||
@ -835,7 +835,7 @@ mod tests {
|
||||
},
|
||||
comment: None,
|
||||
newline: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo {
|
||||
start: Pos {
|
||||
line: 1,
|
||||
@ -868,14 +868,14 @@ mod tests {
|
||||
EntryOption {
|
||||
line_terminators: vec![],
|
||||
space0: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo {
|
||||
start: Pos { line: 1, column: 1 },
|
||||
end: Pos { line: 1, column: 1 },
|
||||
},
|
||||
},
|
||||
space1: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo {
|
||||
start: Pos { line: 1, column: 7 },
|
||||
end: Pos { line: 1, column: 7 },
|
||||
@ -900,7 +900,7 @@ mod tests {
|
||||
}),
|
||||
line_terminator0: LineTerminator {
|
||||
space0: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo {
|
||||
start: Pos {
|
||||
line: 1,
|
||||
@ -914,7 +914,7 @@ mod tests {
|
||||
},
|
||||
comment: None,
|
||||
newline: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo {
|
||||
start: Pos {
|
||||
line: 1,
|
||||
@ -946,14 +946,14 @@ mod tests {
|
||||
VariableDefinition {
|
||||
name: "a".to_string(),
|
||||
space0: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo {
|
||||
start: Pos { line: 1, column: 2 },
|
||||
end: Pos { line: 1, column: 2 },
|
||||
},
|
||||
},
|
||||
space1: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo {
|
||||
start: Pos { line: 1, column: 3 },
|
||||
end: Pos { line: 1, column: 3 },
|
||||
@ -1040,7 +1040,7 @@ mod tests {
|
||||
file_value(&mut reader).unwrap(),
|
||||
FileValue {
|
||||
space0: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 6, 1, 6),
|
||||
},
|
||||
filename: Filename {
|
||||
@ -1048,11 +1048,11 @@ mod tests {
|
||||
source_info: SourceInfo::new(1, 6, 1, 15),
|
||||
},
|
||||
space1: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 15, 1, 15),
|
||||
},
|
||||
space2: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 16, 1, 16),
|
||||
},
|
||||
content_type: None,
|
||||
@ -1063,7 +1063,7 @@ mod tests {
|
||||
file_value(&mut reader).unwrap(),
|
||||
FileValue {
|
||||
space0: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 6, 1, 6),
|
||||
},
|
||||
filename: Filename {
|
||||
@ -1071,7 +1071,7 @@ mod tests {
|
||||
source_info: SourceInfo::new(1, 6, 1, 15),
|
||||
},
|
||||
space1: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 15, 1, 15),
|
||||
},
|
||||
space2: Whitespace {
|
||||
@ -1244,7 +1244,7 @@ mod tests {
|
||||
Predicate {
|
||||
not: false,
|
||||
space0: Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 21, 1, 21),
|
||||
},
|
||||
predicate_func: PredicateFunc {
|
||||
@ -1271,12 +1271,12 @@ mod tests {
|
||||
Section {
|
||||
line_terminators: vec![],
|
||||
space0: Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 1, 1, 1),
|
||||
},
|
||||
line_terminator0: LineTerminator {
|
||||
space0: Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 12, 1, 12),
|
||||
},
|
||||
comment: None,
|
||||
@ -1288,7 +1288,7 @@ mod tests {
|
||||
value: SectionValue::BasicAuth(Some(KeyValue {
|
||||
line_terminators: vec![],
|
||||
space0: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(2, 1, 2, 1)
|
||||
},
|
||||
key: EncodedString {
|
||||
@ -1298,11 +1298,11 @@ mod tests {
|
||||
source_info: SourceInfo::new(2, 1, 2, 5),
|
||||
},
|
||||
space1: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(2, 5, 2, 5)
|
||||
},
|
||||
space2: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(2, 6, 2, 6)
|
||||
},
|
||||
value: Template {
|
||||
@ -1315,7 +1315,7 @@ mod tests {
|
||||
},
|
||||
line_terminator0: LineTerminator {
|
||||
space0: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(2, 14, 2, 14)
|
||||
},
|
||||
comment: None,
|
||||
@ -1336,12 +1336,12 @@ mod tests {
|
||||
Section {
|
||||
line_terminators: vec![],
|
||||
space0: Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 1, 1, 1),
|
||||
},
|
||||
line_terminator0: LineTerminator {
|
||||
space0: Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 12, 1, 12),
|
||||
},
|
||||
comment: None,
|
||||
|
@ -79,8 +79,8 @@ pub fn unquoted_template(reader: &mut Reader) -> ParseResult<'static, Template>
|
||||
|
||||
pub fn unquoted_string_key(reader: &mut Reader) -> ParseResult<'static, EncodedString> {
|
||||
let start = reader.state.pos.clone();
|
||||
let mut value = "".to_string();
|
||||
let mut encoded = "".to_string();
|
||||
let mut value = String::new();
|
||||
let mut encoded = String::new();
|
||||
loop {
|
||||
let save = reader.state.clone();
|
||||
match escape_char(reader) {
|
||||
@ -409,7 +409,7 @@ mod tests {
|
||||
},
|
||||
TemplateElement::Expression(Expr {
|
||||
space0: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 14, 1, 14),
|
||||
},
|
||||
variable: Variable {
|
||||
@ -417,7 +417,7 @@ mod tests {
|
||||
source_info: SourceInfo::new(1, 14, 1, 18),
|
||||
},
|
||||
space1: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 18, 1, 18),
|
||||
},
|
||||
}),
|
||||
|
@ -34,8 +34,8 @@ pub fn templatize(encoded_string: EncodedString) -> ParseResult<'static, Vec<Tem
|
||||
|
||||
let mut elements = vec![];
|
||||
|
||||
let mut value = "".to_string();
|
||||
let mut encoded = "".to_string();
|
||||
let mut value = String::new();
|
||||
let mut encoded = String::new();
|
||||
let mut state = State::String;
|
||||
let mut expression_start = None;
|
||||
|
||||
@ -54,8 +54,8 @@ pub fn templatize(encoded_string: EncodedString) -> ParseResult<'static, Vec<Tem
|
||||
if s.as_str() == "{" {
|
||||
if !value.is_empty() {
|
||||
elements.push(TemplateElement::String { value, encoded });
|
||||
value = "".to_string();
|
||||
encoded = "".to_string();
|
||||
value = String::new();
|
||||
encoded = String::new();
|
||||
}
|
||||
state = State::Template;
|
||||
} else {
|
||||
@ -89,8 +89,8 @@ pub fn templatize(encoded_string: EncodedString) -> ParseResult<'static, Vec<Tem
|
||||
};
|
||||
let expression = expr::parse2(&mut reader)?;
|
||||
elements.push(TemplateElement::Expression(expression));
|
||||
value = "".to_string();
|
||||
encoded = "".to_string();
|
||||
value = String::new();
|
||||
encoded = String::new();
|
||||
expression_start = None;
|
||||
state = State::String;
|
||||
} else {
|
||||
@ -225,7 +225,7 @@ mod tests {
|
||||
},
|
||||
TemplateElement::Expression(Expr {
|
||||
space0: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 11, 1, 11),
|
||||
},
|
||||
variable: Variable {
|
||||
@ -233,7 +233,7 @@ mod tests {
|
||||
source_info: SourceInfo::new(1, 11, 1, 15),
|
||||
},
|
||||
space1: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 15, 1, 15),
|
||||
},
|
||||
}),
|
||||
@ -262,7 +262,7 @@ mod tests {
|
||||
templatize(encoded_string).unwrap(),
|
||||
vec![TemplateElement::Expression(Expr {
|
||||
space0: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 3, 1, 3),
|
||||
},
|
||||
variable: Variable {
|
||||
@ -270,7 +270,7 @@ mod tests {
|
||||
source_info: SourceInfo::new(1, 3, 1, 4),
|
||||
},
|
||||
space1: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 4, 1, 4),
|
||||
},
|
||||
}),]
|
||||
|
@ -27,7 +27,7 @@ pub fn url(reader: &mut Reader) -> ParseResult<'static, Template> {
|
||||
|
||||
let start = reader.state.clone();
|
||||
let mut elements = vec![];
|
||||
let mut buffer = String::from("");
|
||||
let mut buffer = String::new();
|
||||
|
||||
if reader.is_eof() {
|
||||
return Err(Error {
|
||||
@ -62,7 +62,7 @@ pub fn url(reader: &mut Reader) -> ParseResult<'static, Template> {
|
||||
value: buffer.clone(),
|
||||
encoded: buffer.clone(),
|
||||
});
|
||||
buffer = String::from("");
|
||||
buffer = String::new();
|
||||
}
|
||||
elements.push(TemplateElement::Expression(value));
|
||||
}
|
||||
@ -196,7 +196,7 @@ mod tests {
|
||||
},
|
||||
TemplateElement::Expression(Expr {
|
||||
space0: Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 10, 1, 10),
|
||||
},
|
||||
variable: Variable {
|
||||
@ -204,7 +204,7 @@ mod tests {
|
||||
source_info: SourceInfo::new(1, 10, 1, 14),
|
||||
},
|
||||
space1: Whitespace {
|
||||
value: String::from(""),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(1, 14, 1, 14),
|
||||
},
|
||||
}),
|
||||
|
@ -23,7 +23,7 @@ use crate::parser::reader::Reader;
|
||||
use crate::parser::ParseResult;
|
||||
|
||||
pub fn parse(reader: &mut Reader) -> ParseResult<'static, String> {
|
||||
let mut buf = String::from("");
|
||||
let mut buf = String::new();
|
||||
let start = reader.state.clone();
|
||||
match reader.read() {
|
||||
Some('<') => buf.push('<'),
|
||||
|
@ -85,7 +85,7 @@ impl Parser {
|
||||
if self.end_of_string() {
|
||||
return Ok(None);
|
||||
}
|
||||
let mut value = "".to_string();
|
||||
let mut value = String::new();
|
||||
if let Some((delimiter, escaping)) = self.delimiter() {
|
||||
while let Some(c1) = self.read() {
|
||||
if c1 == '\\' && escaping {
|
||||
|
@ -48,7 +48,7 @@ pub fn parse(s: &str) -> Result<String, String> {
|
||||
.split(s)
|
||||
.filter(|s| !s.is_empty())
|
||||
.collect();
|
||||
let mut s = "".to_string();
|
||||
let mut s = String::new();
|
||||
for (i, line) in lines.iter().enumerate() {
|
||||
let hurl_str = parse_line(line).map_err(|message| {
|
||||
format!("Can not parse curl command at line {}: {message}", i + 1)
|
||||
|
@ -672,7 +672,7 @@ pub mod tests {
|
||||
|
||||
fn whitespace() -> Whitespace {
|
||||
Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(0, 0, 0, 0),
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ use hurl_core::ast::*;
|
||||
use crate::format::token::*;
|
||||
|
||||
pub fn format(hurl_file: HurlFile, color: bool) -> String {
|
||||
let mut buffer = String::from("");
|
||||
let mut buffer = String::new();
|
||||
for token in hurl_file.tokenize() {
|
||||
buffer.push_str(format_token(token, color).as_str());
|
||||
}
|
||||
|
@ -556,7 +556,7 @@ fn lint_file_param(file_param: &FileParam) -> FileParam {
|
||||
|
||||
fn empty_whitespace() -> Whitespace {
|
||||
Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: SourceInfo::new(0, 0, 0, 0),
|
||||
}
|
||||
}
|
||||
@ -595,7 +595,7 @@ fn lint_line_terminator(line_terminator: &LineTerminator) -> LineTerminator {
|
||||
let comment = line_terminator.comment.as_ref().map(lint_comment);
|
||||
let newline = Whitespace {
|
||||
value: if line_terminator.newline.value.is_empty() {
|
||||
"".to_string()
|
||||
String::new()
|
||||
} else {
|
||||
"\n".to_string()
|
||||
},
|
||||
|
@ -51,7 +51,7 @@ fn main() {
|
||||
init_colored();
|
||||
|
||||
let log_error_message = cli::make_logger_error_message(opts.color);
|
||||
let mut output_all = "".to_string();
|
||||
let mut output_all = String::new();
|
||||
for input_file in &opts.input_files {
|
||||
match cli::read_to_string(input_file) {
|
||||
Ok(contents) => {
|
||||
|
@ -26,7 +26,7 @@ use proptest::prelude::*;
|
||||
|
||||
fn whitespace() -> BoxedStrategy<String> {
|
||||
prop_oneof![
|
||||
Just("".to_string()),
|
||||
Just(String::new()),
|
||||
Just(" ".to_string()),
|
||||
Just(" ".to_string()),
|
||||
]
|
||||
@ -81,12 +81,12 @@ fn value_string() -> BoxedStrategy<JsonValue> {
|
||||
},
|
||||
TemplateElement::Expression(Expr {
|
||||
space0: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: source_info.clone()
|
||||
},
|
||||
variable,
|
||||
space1: Whitespace {
|
||||
value: "".to_string(),
|
||||
value: String::new(),
|
||||
source_info: source_info.clone()
|
||||
},
|
||||
})
|
||||
@ -119,7 +119,7 @@ fn value() -> BoxedStrategy<JsonValue> {
|
||||
JsonValue::List {
|
||||
space0,
|
||||
elements: vec![JsonListElement {
|
||||
space0: "".to_string(),
|
||||
space0: String::new(),
|
||||
value,
|
||||
space1,
|
||||
}],
|
||||
@ -138,7 +138,7 @@ fn value() -> BoxedStrategy<JsonValue> {
|
||||
space0: space00,
|
||||
elements: vec![
|
||||
JsonListElement {
|
||||
space0: "".to_string(),
|
||||
space0: String::new(),
|
||||
value: value0,
|
||||
space1: space01
|
||||
},
|
||||
@ -163,7 +163,7 @@ fn value() -> BoxedStrategy<JsonValue> {
|
||||
space0: space00,
|
||||
elements: vec![
|
||||
JsonListElement {
|
||||
space0: "".to_string(),
|
||||
space0: String::new(),
|
||||
value: value0,
|
||||
space1: space01
|
||||
},
|
||||
@ -188,7 +188,7 @@ fn value() -> BoxedStrategy<JsonValue> {
|
||||
space0: space00,
|
||||
elements: vec![
|
||||
JsonListElement {
|
||||
space0: "".to_string(),
|
||||
space0: String::new(),
|
||||
value: value0,
|
||||
space1: space01
|
||||
},
|
||||
@ -216,7 +216,7 @@ fn value() -> BoxedStrategy<JsonValue> {
|
||||
JsonValue::Object {
|
||||
space0,
|
||||
elements: vec![JsonObjectElement {
|
||||
space0: "".to_string(),
|
||||
space0: String::new(),
|
||||
name: Template {
|
||||
delimiter: None,
|
||||
elements: vec![TemplateElement::String {
|
||||
|
Loading…
Reference in New Issue
Block a user