Skip to content
This repository has been archived by the owner on Jun 28, 2024. It is now read-only.

Commit

Permalink
Fix by clippy suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
zakarumych committed Oct 18, 2020
1 parent 51c1316 commit dc25f8b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 19 deletions.
24 changes: 10 additions & 14 deletions src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,19 +130,17 @@ impl<K> Cache<K> {
where
S: Spawn + Send + Sync + 'static,
{
let cache = Cache {
#[cfg(feature = "trace")]
tracing::info!("Creating new asset cache");

Cache {
registry,
inner: Arc::new(Inner {
cache: Mutex::default(),
processor: Processor::new(),
spawn: SpawnWrapper { spawn },
}),
};

#[cfg(feature = "trace")]
tracing::info!("New asset Cache created");

cache
}
}

/// Creates new asset cache.
Expand All @@ -152,19 +150,17 @@ impl<K> Cache<K> {
where
S: LocalSpawn + Send + Sync + 'static,
{
let cache = Cache {
#[cfg(feature = "trace")]
tracing::info!("Creating new asset cache");

Cache {
registry,
inner: Arc::new(Inner {
cache: Mutex::default(),
processor: Processor::new(),
spawn: LocalSpawnWrapper { spawn },
}),
};

#[cfg(feature = "trace")]
tracing::info!("New asset Cache created");

cache
}
}

/// Requests an asset by the `key`.
Expand Down
10 changes: 5 additions & 5 deletions src/source/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ where
fn read(&self, path_or_url: &P) -> BoxFuture<'_, Result<Vec<u8>, SourceError>> {
let path_or_url: &str = path_or_url.as_ref();

let path = if path_or_url.starts_with("file://") {
let path = if path_or_url["file://".len()..].starts_with("/") {
&path_or_url["file:///".len()..]
} else if path_or_url["file://".len()..].starts_with("localhost/") {
&path_or_url["file://localhost/".len()..]
let path = if let Some(stripped) = path_or_url.strip_prefix("file://") {
let path = if let Some(file_path) = stripped.strip_prefix('/') {
file_path
} else if let Some(localhost_path) = stripped.strip_prefix("localhost/") {
localhost_path
} else {
return Box::pin(ready(Err(SourceError::NotFound)));
};
Expand Down

0 comments on commit dc25f8b

Please sign in to comment.