Skip to content

Commit fe82442

Browse files
committed
style: update formatting
Signed-off-by: Christina Sørensen <ces@fem.gg>
1 parent 718d0f7 commit fe82442

File tree

24 files changed

+135
-76
lines changed

24 files changed

+135
-76
lines changed

src/fs/dir.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ impl Dir {
5050

5151
/// Produce an iterator of IO results of trying to read all the files in
5252
/// this directory.
53-
#[must_use] pub fn files<'dir, 'ig>(
53+
#[must_use]
54+
pub fn files<'dir, 'ig>(
5455
&'dir self,
5556
dots: DotFilter,
5657
git: Option<&'ig GitCache>,
@@ -71,12 +72,14 @@ impl Dir {
7172
}
7273

7374
/// Whether this directory contains a file with the given path.
74-
#[must_use] pub fn contains(&self, path: &Path) -> bool {
75+
#[must_use]
76+
pub fn contains(&self, path: &Path) -> bool {
7577
self.contents.iter().any(|p| p.path().as_path() == path)
7678
}
7779

7880
/// Append a path onto the path specified by this directory.
79-
#[must_use] pub fn join(&self, child: &Path) -> PathBuf {
81+
#[must_use]
82+
pub fn join(&self, child: &Path) -> PathBuf {
8083
self.path.join(child)
8184
}
8285
}

src/fs/dir_action.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,17 @@ pub enum DirAction {
4343

4444
impl DirAction {
4545
/// Gets the recurse options, if this dir action has any.
46-
#[must_use] pub fn recurse_options(self) -> Option<RecurseOptions> {
46+
#[must_use]
47+
pub fn recurse_options(self) -> Option<RecurseOptions> {
4748
match self {
4849
Self::Recurse(o) => Some(o),
4950
_ => None,
5051
}
5152
}
5253

5354
/// Whether to treat directories as regular files or not.
54-
#[must_use] pub fn treat_dirs_as_files(self) -> bool {
55+
#[must_use]
56+
pub fn treat_dirs_as_files(self) -> bool {
5557
match self {
5658
Self::AsFile => true,
5759
Self::Recurse(o) => o.tree,
@@ -74,7 +76,8 @@ pub struct RecurseOptions {
7476

7577
impl RecurseOptions {
7678
/// Returns whether a directory of the given depth would be too deep.
77-
#[must_use] pub fn is_too_deep(self, depth: usize) -> bool {
79+
#[must_use]
80+
pub fn is_too_deep(self, depth: usize) -> bool {
7881
match self.max_depth {
7982
None => false,
8083
Some(d) => d <= depth,

src/fs/feature/git.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,13 @@ pub struct GitCache {
3131
}
3232

3333
impl GitCache {
34-
#[must_use] pub fn has_anything_for(&self, index: &Path) -> bool {
34+
#[must_use]
35+
pub fn has_anything_for(&self, index: &Path) -> bool {
3536
self.repos.iter().any(|e| e.has_path(index))
3637
}
3738

38-
#[must_use] pub fn get(&self, index: &Path, prefix_lookup: bool) -> f::Git {
39+
#[must_use]
40+
pub fn get(&self, index: &Path, prefix_lookup: bool) -> f::Git {
3941
self.repos
4042
.iter()
4143
.find(|repo| repo.has_path(index))
@@ -410,7 +412,8 @@ fn current_branch(repo: &git2::Repository) -> Option<String> {
410412
}
411413

412414
impl f::SubdirGitRepo {
413-
#[must_use] pub fn from_path(dir: &Path, status: bool) -> Self {
415+
#[must_use]
416+
pub fn from_path(dir: &Path, status: bool) -> Self {
414417
let path = &reorient(dir);
415418

416419
if let Ok(repo) = git2::Repository::open(path) {

src/fs/fields.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ pub enum Type {
6262
}
6363

6464
impl Type {
65-
#[must_use] pub fn is_regular_file(self) -> bool {
65+
#[must_use]
66+
pub fn is_regular_file(self) -> bool {
6667
matches!(self, Self::File)
6768
}
6869
}

src/fs/file.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,18 +209,21 @@ impl<'dir> File<'dir> {
209209
file
210210
}
211211

212-
#[must_use] pub fn new_aa_current(parent_dir: &'dir Dir, total_size: bool) -> File<'dir> {
212+
#[must_use]
213+
pub fn new_aa_current(parent_dir: &'dir Dir, total_size: bool) -> File<'dir> {
213214
File::new_aa(parent_dir.path.clone(), parent_dir, ".", total_size)
214215
}
215216

216-
#[must_use] pub fn new_aa_parent(path: PathBuf, parent_dir: &'dir Dir, total_size: bool) -> File<'dir> {
217+
#[must_use]
218+
pub fn new_aa_parent(path: PathBuf, parent_dir: &'dir Dir, total_size: bool) -> File<'dir> {
217219
File::new_aa(path, parent_dir, "..", total_size)
218220
}
219221

220222
/// A file’s name is derived from its string. This needs to handle directories
221223
/// such as `/` or `..`, which have no `file_name` component. So instead, just
222224
/// use the last component as the name.
223-
#[must_use] pub fn filename(path: &Path) -> String {
225+
#[must_use]
226+
pub fn filename(path: &Path) -> String {
224227
if let Some(back) = path.components().next_back() {
225228
back.as_os_str().to_string_lossy().to_string()
226229
} else {
@@ -1016,7 +1019,8 @@ pub enum FileTarget<'dir> {
10161019
impl<'dir> FileTarget<'dir> {
10171020
/// Whether this link doesn’t lead to a file, for whatever reason. This
10181021
/// gets used to determine how to highlight the link in grid views.
1019-
#[must_use] pub fn is_broken(&self) -> bool {
1022+
#[must_use]
1023+
pub fn is_broken(&self) -> bool {
10201024
matches!(self, Self::Broken(_) | Self::Err(_))
10211025
}
10221026
}

src/fs/filter.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,8 @@ impl IgnorePatterns {
365365
}
366366

367367
/// Create a new empty set of patterns that matches nothing.
368-
#[must_use] pub fn empty() -> Self {
368+
#[must_use]
369+
pub fn empty() -> Self {
369370
Self {
370371
patterns: Vec::new(),
371372
}

src/fs/recursive_size.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ impl RecursiveSize {
3737
/// assert_eq!(x.is_none(), false);
3838
/// ```
3939
#[inline]
40-
#[must_use] pub const fn is_none(&self) -> bool {
40+
#[must_use]
41+
pub const fn is_none(&self) -> bool {
4142
matches!(*self, Self::None)
4243
}
4344

@@ -53,7 +54,8 @@ impl RecursiveSize {
5354
/// assert_eq!(RecursiveSize::Some(2, 3).unwrap_bytes_or(1), 2);
5455
/// ```
5556
#[inline]
56-
#[must_use] pub const fn unwrap_bytes_or(self, default: u64) -> u64 {
57+
#[must_use]
58+
pub const fn unwrap_bytes_or(self, default: u64) -> u64 {
5759
match self {
5860
Self::Some(bytes, _blocks) => bytes,
5961
_ => default,

src/options/config.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
// SPDX-FileCopyrightText: 2014 Benjamin Sago
66
// SPDX-License-Identifier: MIT
77
use crate::theme::ThemeFileType as FileType;
8-
use crate::theme::{FileKinds, FileNameStyle, Git, GitRepo, IconStyle, Links, Permissions, SELinuxContext, SecurityContext, Size, UiStyles, Users};
8+
use crate::theme::{
9+
FileKinds, FileNameStyle, Git, GitRepo, IconStyle, Links, Permissions, SELinuxContext,
10+
SecurityContext, Size, UiStyles, Users,
11+
};
912
use nu_ansi_term::{Color, Style};
1013
use serde::{Deserialize, Deserializer, Serialize};
1114
use serde_norway;
@@ -604,10 +607,12 @@ impl FromOverride<UiStylesOverride> for UiStyles {
604607
}
605608
}
606609
impl ThemeConfig {
607-
#[must_use] pub fn from_path(path: PathBuf) -> Self {
610+
#[must_use]
611+
pub fn from_path(path: PathBuf) -> Self {
608612
ThemeConfig { location: path }
609613
}
610-
#[must_use] pub fn to_theme(&self) -> Option<UiStyles> {
614+
#[must_use]
615+
pub fn to_theme(&self) -> Option<UiStyles> {
611616
let ui_styles_override: Option<UiStylesOverride> = {
612617
let file = std::fs::File::open(&self.location).ok()?;
613618
serde_norway::from_reader(&file).ok()

src/options/error.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ impl fmt::Display for OptionsError {
109109
impl OptionsError {
110110
/// Try to second-guess what the user was trying to do, depending on what
111111
/// went wrong.
112-
#[must_use] pub fn suggestion(&self) -> Option<&'static str> {
112+
#[must_use]
113+
pub fn suggestion(&self) -> Option<&'static str> {
113114
// ‘ls -lt’ and ‘ls -ltr’ are common combinations
114115
match self {
115116
Self::BadArgument(time, r) if *time == &flags::TIME && r == "r" => {

src/options/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,8 @@ impl Options {
173173
/// Whether the View specified in this set of options includes a Git
174174
/// status column. It’s only worth trying to discover a repository if the
175175
/// results will end up being displayed.
176-
#[must_use] pub fn should_scan_for_git(&self) -> bool {
176+
#[must_use]
177+
pub fn should_scan_for_git(&self) -> bool {
177178
if self.filter.git_ignore == GitIgnore::CheckAndIgnore {
178179
return true;
179180
}

0 commit comments

Comments
 (0)