Merge pull request #185 from Orange-OpenSource/feature/update-rust-1.52

Update to Rust 1.52
This commit is contained in:
Fabrice Reix 2021-05-14 16:43:04 +02:00 committed by GitHub
commit a0239a695f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 18 additions and 41 deletions

View File

@ -62,10 +62,7 @@ impl Reader {
}
pub fn peek(&mut self) -> Option<char> {
match self.buffer.get(self.state.cursor) {
None => None,
Some(c) => Some(*c),
}
self.buffer.get(self.state.cursor).copied()
}
pub fn read_while(&mut self, predicate: fn(&char) -> bool) -> String {

View File

@ -306,7 +306,7 @@ fn variables(matches: ArgMatches) -> Result<HashMap<String, Value>, CliError> {
Err(_) => {
return Err(CliError {
message: format!("Can not parse line {} of {}", index + 1, path.display()),
})
});
}
};
let line = line.trim();
@ -581,6 +581,7 @@ fn parse_options(matches: ArgMatches) -> Result<CliOptions, CliError> {
color,
fail_fast,
insecure,
interactive,
variables,
to_entry,
follow_location,
@ -592,7 +593,6 @@ fn parse_options(matches: ArgMatches) -> Result<CliOptions, CliError> {
connect_timeout,
compressed,
user,
interactive,
})
}
@ -618,10 +618,7 @@ fn main() {
let current_dir_buf = std::env::current_dir().unwrap();
let current_dir = current_dir_buf.as_path();
let file_root = match matches.value_of("file_root") {
Some(value) => Some(value.to_string()),
_ => None,
};
let file_root = matches.value_of("file_root").map(|value| value.to_string());
let verbose = matches.is_present("verbose") || matches.is_present("interactive");
let log_verbose = cli::make_logger_verbose(verbose);
let color = output_color(matches.clone());

View File

@ -91,10 +91,9 @@ impl Response {
/// Extract charset from mime-type String
///
fn mime_charset(mime_type: String) -> Option<String> {
match mime_type.find("charset=") {
None => None,
Some(index) => Some(mime_type[(index + 8)..].to_string()),
}
mime_type
.find("charset=")
.map(|index| mime_type[(index + 8)..].to_string())
}
#[cfg(test)]

View File

@ -166,12 +166,12 @@ pub fn parse_request(value: serde_json::Value) -> Result<Request, ParseError> {
Ok(Request {
method,
url,
querystring,
headers,
querystring,
form,
multipart,
cookies,
body,
multipart,
form,
content_type,
})
} else {

View File

@ -62,10 +62,7 @@ impl Reader {
}
pub fn peek(&mut self) -> Option<char> {
match self.buffer.get(self.state.cursor) {
None => None,
Some(c) => Some(*c),
}
self.buffer.get(self.state.cursor).copied()
}
pub fn read_while(&mut self, predicate: fn(&char) -> bool) -> String {

View File

@ -93,9 +93,9 @@ fn section(reader: &mut Reader) -> ParseResult<'static, Section> {
Ok(Section {
line_terminators,
space0,
source_info,
line_terminator0,
value,
source_info,
})
}

View File

@ -128,9 +128,9 @@ pub fn unquoted_string_key(reader: &mut Reader) -> ParseResult<'static, EncodedS
let end = reader.state.pos.clone();
let source_info = SourceInfo { start, end };
Ok(EncodedString {
quotes,
encoded,
value,
encoded,
quotes,
source_info,
})
}

View File

@ -46,10 +46,7 @@ impl Lintable<Entry> for Entry {
fn lint(&self) -> Entry {
Entry {
request: self.request.lint(),
response: match self.clone().response {
None => None,
Some(response) => Some(response.lint()),
},
response: self.clone().response.map(|response| response.lint()),
}
}
}
@ -84,10 +81,7 @@ impl Lintable<Request> for Request {
let url = self.url.clone();
let line_terminator0 = self.line_terminator0.lint();
let headers = self.headers.iter().map(|e| e.lint()).collect();
let b = match self.clone().body {
None => None,
Some(body) => Some(body.lint()),
};
let b = self.clone().body.map(|body| body.lint());
let mut sections: Vec<Section> = self.sections.iter().map(|e| e.lint()).collect();
sections.sort_by_key(|k| section_value_index(k.value.clone()));
@ -275,11 +269,7 @@ impl Lintable<QueryValue> for QueryValue {
expr: CookiePath { name, attribute },
..
} => {
let attribute = if let Some(attribute) = attribute {
Some(attribute.lint())
} else {
None
};
let attribute = attribute.as_ref().map(|attribute| attribute.lint());
QueryValue::Cookie {
space0: one_whitespace(),
expr: CookiePath {
@ -704,10 +694,7 @@ impl Lintable<LineTerminator> for LineTerminator {
source_info: SourceInfo::init(0, 0, 0, 0),
},
};
let comment = match self.clone().comment {
None => None,
Some(comment) => Some(comment.lint()),
};
let comment = self.clone().comment.map(|comment| comment.lint());
let newline = Whitespace {
value: if self.newline.value.is_empty() {
"".to_string()