If-let instead of unwrap (PR #1746 follow-up) (#1770)

Solves: https://github.com/astral-sh/uv/pull/1746#discussion_r1496139629
This commit is contained in:
konsti 2024-02-20 18:32:01 +01:00 committed by GitHub
parent ede2828fde
commit a269766c27
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -983,16 +983,17 @@ fn parse(cursor: &mut Cursor, working_dir: Option<&Path>) -> Result<Requirement,
cursor.eat_whitespace();
if let Some((pos, char)) = cursor.next() {
if let Some(VersionOrUrl::Url(url)) = requirement_kind {
// Unwrap safety: The `VerbatimUrl` we just parsed has a string source.
if url.given().unwrap().ends_with(';') && marker.is_none() {
return Err(Pep508Error {
message: Pep508ErrorSource::String(
"Missing space before ';', the end of the URL is ambiguous".to_string(),
),
start: requirement_end - ';'.len_utf8(),
len: ';'.len_utf8(),
input: cursor.to_string(),
});
if let Some(given) = url.given() {
if given.ends_with(';') && marker.is_none() {
return Err(Pep508Error {
message: Pep508ErrorSource::String(
"Missing space before ';', the end of the URL is ambiguous".to_string(),
),
start: requirement_end - ';'.len_utf8(),
len: ';'.len_utf8(),
input: cursor.to_string(),
});
}
}
}
let message = if marker.is_none() {