INNER CODE UNIT · Rust

asset_from_cache

sharkdp/bat · src/assets.rs:410

fn asset_from_cache<T: serde::de::DeserializeOwned>(
    path: &Path,
    description: &str,
    compressed: bool,
) -> Result<T> {
    let contents = fs::read(path).map_err(|_| {
        format!(
            "Could not load cached {description} '{}'",
            path.to_string_lossy()
        )
    })?;
    asset_from_contents(&contents[..], description, compressed)
        .map_err(|_| format!("Could not parse cached {description}").into())
}

#[cfg(test)]
mod tests {
    use super::*;

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…