Skip to content

Commit

Permalink
Use return impl
Browse files Browse the repository at this point in the history
  • Loading branch information
quambene committed Jan 1, 2024
1 parent 0e4c3e0 commit ef56a20
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub trait Caching {

/// Open the cached file for a bookmark.
// TODO: return `Result<Option<impl Read>, anyhow::Error>` (see <https://github.com/rust-lang/rust/issues/91611>).
fn open(&self, bookmark: &TargetBookmark) -> Result<Option<File>, BogrepError>;
fn open(&self, bookmark: &TargetBookmark) -> Result<Option<impl Read>, BogrepError>;

/// Get the content of a bookmark from cache.
// TODO: make get async
Expand Down Expand Up @@ -153,7 +153,7 @@ impl Caching for Cache {
bookmark.cache_modes.contains(self.mode())
}

fn open(&self, bookmark: &TargetBookmark) -> Result<Option<File>, BogrepError> {
fn open(&self, bookmark: &TargetBookmark) -> Result<Option<impl Read>, BogrepError> {
let cache_path = self.bookmark_path(&bookmark.id);
debug!("Open website: {}", cache_path.display());

Expand Down Expand Up @@ -322,8 +322,8 @@ impl Caching for MockCache {
self.get(bookmark).unwrap().is_some()
}

fn open(&self, _bookmark: &TargetBookmark) -> Result<Option<File>, BogrepError> {
Ok(None)
fn open(&self, _bookmark: &TargetBookmark) -> Result<Option<impl Read>, BogrepError> {
Ok(None::<File>)

Check warning on line 326 in src/cache.rs

View check run for this annotation

Codecov / codecov/patch

src/cache.rs#L325-L326

Added lines #L325 - L326 were not covered by tests
}

fn get(&self, bookmark: &TargetBookmark) -> Result<Option<String>, BogrepError> {
Expand Down

0 comments on commit ef56a20

Please sign in to comment.