Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating rustfmt #144

Merged
merged 1 commit into from
Nov 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Updating rustfmt
  • Loading branch information
marcospb19 committed Nov 2, 2021
commit 27b6970edae5a4a6156e32ba49f05ad8f45aedae
4 changes: 2 additions & 2 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::{env, fs::create_dir_all, path::Path};

use clap::{ArgEnum, IntoApp};
use clap_generate::{generate_to, Shell};

use std::{env, fs::create_dir_all, path::Path};

include!("src/opts.rs");

fn main() {
Expand Down
5 changes: 5 additions & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Stable features
max_width = 120
use_field_init_shorthand = true
newline_style = "Unix"
Expand All @@ -6,5 +7,9 @@ reorder_imports = true
reorder_modules = true
use_try_shorthand = true
use_small_heuristics = "Max"

# Unstable features (nightly only)
unstable_features = true
force_multiline_blocks = true
group_imports = "StdExternalCrate"
imports_granularity = "Crate"
10 changes: 3 additions & 7 deletions src/archive/zip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,17 @@ use std::{
};

use fs_err as fs;

use walkdir::WalkDir;
use zip::{self, read::ZipFile, ZipArchive};

use self::utf8::get_invalid_utf8_paths;
use crate::{
info,
list::FileInArchive,
utils::{self, dir_is_empty, strip_cur_dir, Bytes},
QuestionPolicy,
};

use self::utf8::get_invalid_utf8_paths;

/// Unpacks the archive given by `archive` into the folder given by `into`.
pub fn unpack_archive<R>(
mut archive: ZipArchive<R>,
Expand Down Expand Up @@ -158,8 +156,7 @@ fn check_for_comments(file: &ZipFile) {

#[cfg(unix)]
fn __unix_set_permissions(file_path: &Path, file: &ZipFile) -> crate::Result<()> {
use std::fs::Permissions;
use std::os::unix::fs::PermissionsExt;
use std::{fs::Permissions, os::unix::fs::PermissionsExt};

if let Some(mode) = file.unix_mode() {
fs::set_permissions(file_path, Permissions::from_mode(mode))?;
Expand All @@ -175,8 +172,7 @@ mod utf8 {
// Sad double reference in order to make `filter` happy in `get_invalid_utf8_paths`
#[cfg(unix)]
fn is_invalid_utf8(path: &&Path) -> bool {
use std::os::unix::prelude::OsStrExt;
use std::str;
use std::{os::unix::prelude::OsStrExt, str};

// str::from_utf8 does not make any allocations
let bytes = path.as_os_str().as_bytes();
Expand Down
11 changes: 6 additions & 5 deletions src/list.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
//! Implementation of the 'list' command, print list of files in an archive

use self::tree::Tree;
use std::path::{Path, PathBuf};

use self::tree::Tree;

/// Options controlling how archive contents should be listed
#[derive(Debug, Clone, Copy)]
pub struct ListOptions {
Expand Down Expand Up @@ -56,11 +57,11 @@ fn print_entry(name: impl std::fmt::Display, is_dir: bool) {
/// we have to construct the tree structure ourselves to be able to
/// display them as a tree
mod tree {
use super::FileInArchive;
use std::{ffi::OsString, iter::FromIterator, path};

use linked_hash_map::LinkedHashMap;
use std::ffi::OsString;
use std::iter::FromIterator;
use std::path;

use super::FileInArchive;

/// Directory tree
#[derive(Debug, Default)]
Expand Down
4 changes: 2 additions & 2 deletions src/opts.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use clap::{Parser, ValueHint};

use std::path::PathBuf;

use clap::{Parser, ValueHint};

/// Command line options
#[derive(Parser, Debug)]
#[clap(version, about)]
Expand Down
3 changes: 1 addition & 2 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ use std::{
cmp, env,
ffi::OsStr,
io,
path::Component,
path::{Path, PathBuf},
path::{Component, Path, PathBuf},
};

use fs_err as fs;
Expand Down
3 changes: 1 addition & 2 deletions tests/compress_and_decompress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ use std::{
time::Duration,
};

use ouch::{commands::run, Opts, QuestionPolicy, Subcommand};

use fs_err as fs;
use ouch::{commands::run, Opts, QuestionPolicy, Subcommand};
use rand::{rngs::SmallRng, RngCore, SeedableRng};
use tempfile::NamedTempFile;
use utils::*;
Expand Down
1 change: 0 additions & 1 deletion tests/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use std::path::{Path, PathBuf};

use fs_err as fs;

use ouch::{commands::run, Opts, QuestionPolicy, Subcommand};

pub fn create_empty_dir(at: &Path, filename: &str) -> PathBuf {
Expand Down