From 2ebdaf6ecfceb4f0ea18ed1e27bbd2178c0eb5b1 Mon Sep 17 00:00:00 2001 From: MisileLaboratory Date: Tue, 18 Apr 2023 04:05:11 +0000 Subject: [PATCH] feat: RefCell remove --- Cargo.toml | 2 +- src/commands/list.rs | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3e52c1b..1e475bb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,7 +34,7 @@ unrar = "0.5.2" xz2 = "0.1.7" zip = { version = "0.6.6", default-features = false, features = ["time"] } zstd = { version = "0.13.0", default-features = false } -sevenz-rust = {version = "0.2.9", features = ["compress"]} +sevenz-rust = {version = "0.2.10", features = ["compress"]} [target.'cfg(not(unix))'.dependencies] is_executable = "1.0.1" diff --git a/src/commands/list.rs b/src/commands/list.rs index a2ae9d1..9d21e36 100644 --- a/src/commands/list.rs +++ b/src/commands/list.rs @@ -1,5 +1,4 @@ use std::{ - cell::RefCell, io::{self, BufReader, Read}, path::Path, }; @@ -89,17 +88,17 @@ pub fn list_archive_contents( } }, SevenZip => { - let a = RefCell::new(Vec::new()); + let mut a = Vec::new(); sevenz_rust::decompress_file_with_extract_fn(archive_path, ".", |entry, _, _| { - a.borrow_mut().push(Ok(FileInArchive { + a.push(Ok(FileInArchive { path: entry.name().into(), is_dir: entry.is_directory(), })); Ok(true) }) .map_err(|e| crate::Error::SevenzipError(e))?; - Box::new(a.into_inner().into_iter()) + Box::new(a.into_iter()) } Gzip | Bzip | Lz4 | Lzma | Snappy | Zstd => { panic!("Not an archive! This should never happen, if it does, something is wrong with `CompressionFormat::is_archive()`. Please report this error!");