Skip to content

Commit

Permalink
Fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
quambene committed Jan 22, 2024
1 parent 05b5486 commit c1d3d4f
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 13 deletions.
3 changes: 1 addition & 2 deletions src/bookmark_reader/target_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ fn convert_underlyings(target_bookmarks: &mut TargetBookmarks) -> Result<(), Bog
if bookmark
.sources
.iter()
.find(|source| matches!(source, SourceType::Underlying(_)))
.is_some()
.any(|source| matches!(source, SourceType::Underlying(_)))
{
Some(bookmark.clone())
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/bookmarks/bookmark_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ where
let cache = &self.cache;

if bookmark.underlying_url.is_none() {
let underlying_url = html::select_underlying(&website, &bookmark.underlying_type)?;
let underlying_url = html::select_underlying(website, &bookmark.underlying_type)?;

if let Some(underlying_url) = underlying_url {
bookmark.underlying_url = Some(underlying_url.clone());
Expand Down
10 changes: 5 additions & 5 deletions src/bookmarks/target_bookmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ impl TargetBookmarks {
) -> Vec<&'a mut TargetBookmark> {
self.0
.iter_mut()
.filter(|(url, _)| !source_bookmarks.contains_key(&url.to_string()))
.filter(|(url, _)| !source_bookmarks.contains_key(url.as_str()))
.map(|(_, target_bookmark)| target_bookmark)
.collect()
}
Expand Down Expand Up @@ -383,19 +383,19 @@ mod tests {
let source_bookmarks = SourceBookmarks::new(HashMap::from_iter([
(
url1.to_string(),
SourceBookmarkBuilder::new(&url1.to_string()).build(),
SourceBookmarkBuilder::new(url1.as_str()).build(),
),
(
url2.to_string(),
SourceBookmarkBuilder::new(&url2.to_string()).build(),
SourceBookmarkBuilder::new(url2.as_str()).build(),
),
(
url3.to_string(),
SourceBookmarkBuilder::new(&url3.to_string()).build(),
SourceBookmarkBuilder::new(url3.as_str()).build(),
),
(
url4.to_string(),
SourceBookmarkBuilder::new(&url4.to_string()).build(),
SourceBookmarkBuilder::new(url4.as_str()).build(),
),
]));
let mut target_bookmarks = TargetBookmarks::new(HashMap::from_iter([
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub async fn fetch(config: &Config, args: &FetchArgs) -> Result<(), anyhow::Erro

fetch_bookmarks(
&config.settings,
&args,
args,
client,
cache,
&mut target_reader,
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/remove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fn remove_urls(
target_reader.read(&mut target_bookmarks)?;

for url in urls {
if target_bookmarks.remove(&url).is_some() {
if target_bookmarks.remove(url).is_some() {
counter += 1;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/html.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ fn is_filtered_tag(tag_name: &QualName) -> bool {
pub fn convert_to_text(html: &str, bookmark_url: &Url) -> Result<String, BogrepError> {
let mut cursor = Cursor::new(html);
let product =
extractor::extract(&mut cursor, &bookmark_url).map_err(BogrepError::ConvertHtml)?;
extractor::extract(&mut cursor, bookmark_url).map_err(BogrepError::ConvertHtml)?;
Ok(product.text)
}

Expand Down
4 changes: 2 additions & 2 deletions src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ impl Settings {
}

pub fn add_ignored_url(&mut self, url: &str) -> Result<(), anyhow::Error> {
let url = Url::parse(&url).context(format!("Invalid url {url}"))?;
let url = Url::parse(url).context(format!("Invalid url {url}"))?;
let normalized_url = url.to_string();

if self.ignored_urls.iter().any(|url| *url == normalized_url) {
Expand All @@ -132,7 +132,7 @@ impl Settings {
}

pub fn add_underlying_url(&mut self, url: &str) -> Result<(), anyhow::Error> {
let url = Url::parse(&url).context(format!("Invalid url {url}"))?;
let url = Url::parse(url).context(format!("Invalid url {url}"))?;
let normalized_url = url.to_string();
let domain = url.domain().ok_or(anyhow!(format!("Invalid url {url}")))?;

Expand Down

0 comments on commit c1d3d4f

Please sign in to comment.