Skip to content

Commit

Permalink
Fixes clippy issues
Browse files Browse the repository at this point in the history
  • Loading branch information
xfbs committed Oct 20, 2024
1 parent bece43d commit 4c49a56
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
13 changes: 4 additions & 9 deletions src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ impl CrateSource {
}

let prefix = format!("{}-{}/", version.krate, version.version);
let mut source = CrateSource {
let source = CrateSource {
version,
files: Self::parse_archive(&prefix, data, true)?,
};
Expand Down Expand Up @@ -330,7 +330,7 @@ impl CrateSource {
// make path encoding error explicit
let bytes = entry.path_bytes();
let path = std::str::from_utf8(&bytes)?;
let path = match path.strip_prefix(&prefix) {
let path = match path.strip_prefix(prefix) {
Some(path) => path,
None if error_outside_prefix => {
return Err(CrateSourceError::InvalidPrefix {
Expand All @@ -349,24 +349,19 @@ impl CrateSource {

debug!("Storing path {path} ({} bytes)", data.len());
// store data
files.insert(path.into(), data.into());
files.insert(path, data.into());
}

Ok(files)
}

/// Add a single file to crate source.
fn add<T: Into<Bytes>>(&mut self, path: &Utf8Path, data: T) {
self.files.insert(path.into(), data.into());
}

/// Get [`CargoVcsInfo`] from the crate sources.
pub fn cargo_vcs_info(&self) -> Result<CargoVcsInfo, CargoVcsInfoError> {
let raw = self
.files
.get(Utf8Path::new(".cargo_vcs_info.json"))
.ok_or(CargoVcsInfoError::Missing)?;
let decoded = serde_json::from_slice(&raw)?;
let decoded = serde_json::from_slice(raw)?;
Ok(decoded)
}
}
Expand Down
5 changes: 1 addition & 4 deletions src/views/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use crate::{
version::VersionId,
};
use camino::Utf8PathBuf;
use log::*;
use std::{rc::Rc, sync::Arc};
use yew::{prelude::*, suspense::*};

Expand Down Expand Up @@ -118,7 +117,7 @@ fn CrateSourceFetcherInner(props: &CrateSourceFetcherProps) -> HtmlResult {

let source = match &*source {
Ok(source) => source.clone(),
Err(error) => {
Err(_error) => {
return Ok(html! {
{"Error fetching source"}
});
Expand Down Expand Up @@ -165,8 +164,6 @@ fn RepoSourceFetcher(props: &RepoSourceFetcherProps) -> Html {
vcs_info,
};

let url = info.url();

let fallback = html! {
{"Loading repository archive"}
};
Expand Down

0 comments on commit 4c49a56

Please sign in to comment.