mirror of
https://github.com/rust-lang-nursery/rust-cookbook
synced 2024-11-22 03:23:05 +00:00
Correct Result<>
This commit is contained in:
parent
752b035c1a
commit
cc37f32c28
1 changed files with 2 additions and 2 deletions
|
@ -20,7 +20,7 @@ use tar::Archive;
|
||||||
# }
|
# }
|
||||||
# }
|
# }
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<(), std::io::Error> {
|
||||||
let file = File::open("archive.tar.gz")?;
|
let file = File::open("archive.tar.gz")?;
|
||||||
let mut archive = Archive::new(GzDecoder::new(file));
|
let mut archive = Archive::new(GzDecoder::new(file));
|
||||||
let prefix = "bundle/logs";
|
let prefix = "bundle/logs";
|
||||||
|
@ -29,7 +29,7 @@ fn main() -> Result<()> {
|
||||||
archive
|
archive
|
||||||
.entries()?
|
.entries()?
|
||||||
.filter_map(|e| e.ok())
|
.filter_map(|e| e.ok())
|
||||||
.map(|mut entry| -> Result<PathBuf> {
|
.map(|mut entry| -> Result<PathBuf, Box<dyn std::error::Error>> {
|
||||||
let path = entry.path()?.strip_prefix(prefix)?.to_owned();
|
let path = entry.path()?.strip_prefix(prefix)?.to_owned();
|
||||||
entry.unpack(&path)?;
|
entry.unpack(&path)?;
|
||||||
Ok(path)
|
Ok(path)
|
||||||
|
|
Loading…
Reference in a new issue