clippy: fix result_unit_err warnings (#31791)

* clippy: fix `result_unit_err` warnings

* feat: fix result warnings in script

* doc: document `generate_key` return type

Co-authored-by: Martin Robinson <mrobinson@igalia.com>

* feat: add back result to RangeRequestBounds::get_final

Co-authored-by: Martin Robinson <mrobinson@igalia.com>

---------

Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
eri 2024-03-21 13:51:45 +01:00 committed by GitHub
parent ea62a5e24f
commit da696b7e57
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 175 additions and 191 deletions

View file

@ -25,6 +25,12 @@ pub struct CookieStorage {
max_per_host: usize,
}
#[derive(Debug)]
pub enum RemoveCookieError {
Overlapping,
NonHTTP,
}
impl CookieStorage {
pub fn new(max_cookies: usize) -> CookieStorage {
CookieStorage {
@ -40,7 +46,7 @@ impl CookieStorage {
cookie: &Cookie,
url: &ServoUrl,
source: CookieSource,
) -> Result<Option<Cookie>, ()> {
) -> Result<Option<Cookie>, RemoveCookieError> {
let domain = reg_host(cookie.cookie.domain().as_ref().unwrap_or(&""));
let cookies = self.cookies_map.entry(domain).or_default();
@ -61,7 +67,7 @@ impl CookieStorage {
});
if any_overlapping {
return Err(());
return Err(RemoveCookieError::Overlapping);
}
}
@ -80,7 +86,7 @@ impl CookieStorage {
if c.cookie.http_only().unwrap_or(false) && source == CookieSource::NonHTTP {
// Undo the removal.
cookies.push(c);
Err(())
Err(RemoveCookieError::NonHTTP)
} else {
Ok(Some(c))
}