Do a rustfmt **/*.rs

This commit is contained in:
sxyazi 2023-09-30 15:20:45 +08:00
parent 284d95a3a3
commit 740e679b13
No known key found for this signature in database
3 changed files with 17 additions and 61 deletions

View file

@ -1,23 +1,17 @@
use core::files::File;
use config::{MANAGER, THEME};
use ratatui::{
buffer::Buffer,
layout::Rect,
style::{Color, Modifier, Style},
text::{Line, Span},
widgets::{List, ListItem, Widget},
};
use ratatui::{buffer::Buffer, layout::Rect, style::{Color, Modifier, Style}, text::{Line, Span}, widgets::{List, ListItem, Widget}};
use shared::short_path;
use crate::Ctx;
pub(super) struct Folder<'a> {
cx: &'a Ctx,
folder: &'a core::manager::Folder,
is_preview: bool,
cx: &'a Ctx,
folder: &'a core::manager::Folder,
is_preview: bool,
is_selection: bool,
is_find: bool,
is_find: bool,
}
impl<'a> Folder<'a> {

View file

@ -7,7 +7,7 @@ use shared::Url;
use crate::files::Files;
pub struct Finder {
query: Regex,
query: Regex,
matched: BTreeMap<Url, u8>,
version: u64,
}
@ -123,14 +123,10 @@ impl Finder {
impl Finder {
#[inline]
pub fn matched(&self) -> &BTreeMap<Url, u8> {
&self.matched
}
pub fn matched(&self) -> &BTreeMap<Url, u8> { &self.matched }
#[inline]
pub fn has_matched(&self) -> bool {
!self.matched.is_empty()
}
pub fn has_matched(&self) -> bool { !self.matched.is_empty() }
#[inline]
pub fn matched_idx(&self, url: &Url) -> Option<u8> {

View file

@ -1,14 +1,7 @@
use std::{
collections::VecDeque,
path::{Path, PathBuf},
};
use std::{collections::VecDeque, path::{Path, PathBuf}};
use anyhow::Result;
use tokio::{
fs, io, select,
sync::{mpsc, oneshot},
time,
};
use tokio::{fs, io, select, sync::{mpsc, oneshot}, time};
pub async fn calculate_size(path: &Path) -> u64 {
let mut total = 0;
@ -102,10 +95,7 @@ pub fn copy_with_progress(from: &Path, to: &Path) -> mpsc::Receiver<Result<u64,
#[cfg(not(target_os = "windows"))]
#[allow(clippy::collapsible_else_if)]
pub fn file_mode(mode: u32) -> String {
use libc::{
S_IFBLK, S_IFCHR, S_IFDIR, S_IFIFO, S_IFLNK, S_IFMT, S_IFSOCK, S_IRGRP, S_IROTH, S_IRUSR,
S_ISGID, S_ISUID, S_ISVTX, S_IWGRP, S_IWOTH, S_IWUSR, S_IXGRP, S_IXOTH, S_IXUSR,
};
use libc::{S_IFBLK, S_IFCHR, S_IFDIR, S_IFIFO, S_IFLNK, S_IFMT, S_IFSOCK, S_IRGRP, S_IROTH, S_IRUSR, S_ISGID, S_ISUID, S_ISVTX, S_IWGRP, S_IWOTH, S_IWUSR, S_IXGRP, S_IXOTH, S_IXUSR};
#[cfg(target_os = "macos")]
let m = mode as u16;
@ -133,51 +123,27 @@ pub fn file_mode(mode: u32) -> String {
s.push(if m & S_IRUSR != 0 { 'r' } else { '-' });
s.push(if m & S_IWUSR != 0 { 'w' } else { '-' });
s.push(if m & S_IXUSR != 0 {
if m & S_ISUID != 0 {
's'
} else {
'x'
}
if m & S_ISUID != 0 { 's' } else { 'x' }
} else {
if m & S_ISUID != 0 {
'S'
} else {
'-'
}
if m & S_ISUID != 0 { 'S' } else { '-' }
});
// Group
s.push(if m & S_IRGRP != 0 { 'r' } else { '-' });
s.push(if m & S_IWGRP != 0 { 'w' } else { '-' });
s.push(if m & S_IXGRP != 0 {
if m & S_ISGID != 0 {
's'
} else {
'x'
}
if m & S_ISGID != 0 { 's' } else { 'x' }
} else {
if m & S_ISGID != 0 {
'S'
} else {
'-'
}
if m & S_ISGID != 0 { 'S' } else { '-' }
});
// Other
s.push(if m & S_IROTH != 0 { 'r' } else { '-' });
s.push(if m & S_IWOTH != 0 { 'w' } else { '-' });
s.push(if m & S_IXOTH != 0 {
if m & S_ISVTX != 0 {
't'
} else {
'x'
}
if m & S_ISVTX != 0 { 't' } else { 'x' }
} else {
if m & S_ISVTX != 0 {
'T'
} else {
'-'
}
if m & S_ISVTX != 0 { 'T' } else { '-' }
});
s