Skip to content

Commit 404b352

Browse files
committed
clean: cargo fmt
1 parent 4a42fda commit 404b352

8 files changed

Lines changed: 65 additions & 52 deletions

File tree

src/app/pages/clipboard.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,16 @@ pub fn clipboard_view(
1616
container(Row::from_vec(vec![
1717
container(
1818
scrollable(
19-
clipboard_content.iter().enumerate().map(|(i, content)| {
20-
// I'd be surprised if you get 4 billion entries
21-
#[allow(clippy::cast_possible_truncation)]
22-
content.to_app().render(theme.clone(), i as u32, focus_id)
23-
}).collect::<Column<_>>()
24-
.width(WINDOW_WIDTH / 3.),
19+
clipboard_content
20+
.iter()
21+
.enumerate()
22+
.map(|(i, content)| {
23+
// I'd be surprised if you get 4 billion entries
24+
#[allow(clippy::cast_possible_truncation)]
25+
content.to_app().render(theme.clone(), i as u32, focus_id)
26+
})
27+
.collect::<Column<_>>()
28+
.width(WINDOW_WIDTH / 3.),
2529
)
2630
.id("results"),
2731
)

src/app/tile/elm.rs

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -200,24 +200,25 @@ pub fn view(tile: &Tile, wid: window::Id) -> Element<'_, Message> {
200200
} else if tile.results.is_empty() {
201201
space().into()
202202
} else if tile.page == Page::EmojiSearch {
203-
let results: Vec<_> = tile.emoji_apps
204-
.search_prefix(&tile.query_lc)
205-
.map(std::borrow::ToOwned::to_owned)
206-
.collect();
207-
208-
emoji_page(
209-
tile.config.theme.clone(),
210-
&results,
211-
tile.focus_id,
212-
)
203+
let results: Vec<_> = tile
204+
.emoji_apps
205+
.search_prefix(&tile.query_lc)
206+
.map(std::borrow::ToOwned::to_owned)
207+
.collect();
208+
209+
emoji_page(tile.config.theme.clone(), &results, tile.focus_id)
213210
} else {
214-
container(tile.results.iter().enumerate().map(
215-
|(i, app)| {
216-
#[allow(clippy::cast_possible_truncation)]
217-
app.clone()
218-
.render(tile.config.theme.clone(), i as u32, tile.focus_id)
219-
}
220-
).collect::<Column<_>>())
211+
container(
212+
tile.results
213+
.iter()
214+
.enumerate()
215+
.map(|(i, app)| {
216+
#[allow(clippy::cast_possible_truncation)]
217+
app.clone()
218+
.render(tile.config.theme.clone(), i as u32, tile.focus_id)
219+
})
220+
.collect::<Column<_>>(),
221+
)
221222
.into()
222223
};
223224

src/app/tile/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,9 @@ fn handle_hot_reloading() -> impl futures::Stream<Item = Message> {
328328

329329
fn count_dirs_in_dir(dir: &PathBuf) -> usize {
330330
// Read the directory; if it fails, treat as empty
331-
let Ok(entries) = fs::read_dir(dir) else { return 0 };
331+
let Ok(entries) = fs::read_dir(dir) else {
332+
return 0;
333+
};
332334

333335
entries
334336
.filter_map(std::result::Result::ok)

src/app/tile/search_query.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,11 @@ pub(super) fn handle_change(tile: &mut Tile, input: &str, id: Id) -> iced::Task<
163163
let max_elem = cmp::min(5, new_length);
164164

165165
if prev_size != new_length && tile.page != Page::ClipboardHistory {
166-
#[allow(clippy::cast_precision_loss, clippy::cast_possible_truncation, clippy::cast_sign_loss)]
166+
#[allow(
167+
clippy::cast_precision_loss,
168+
clippy::cast_possible_truncation,
169+
clippy::cast_sign_loss
170+
)]
167171
Task::batch([
168172
window::resize(
169173
id,
@@ -175,7 +179,11 @@ pub(super) fn handle_change(tile: &mut Tile, input: &str, id: Id) -> iced::Task<
175179
Task::done(Message::ChangeFocus(ArrowKey::Left)),
176180
])
177181
} else if tile.page == Page::ClipboardHistory {
178-
#[allow(clippy::cast_precision_loss, clippy::cast_possible_truncation, clippy::cast_sign_loss)]
182+
#[allow(
183+
clippy::cast_precision_loss,
184+
clippy::cast_possible_truncation,
185+
clippy::cast_sign_loss
186+
)]
179187
Task::batch([
180188
window::resize(
181189
id,

src/app/tile/update.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ pub fn handle_update(tile: &mut Tile, message: Message) -> Task<Message> {
9696
}
9797

9898
Message::ChangeFocus(key) => {
99-
#[allow(clippy::cast_possible_truncation)] // No, there won't be more than 2^32-1 items in a list
99+
#[allow(clippy::cast_possible_truncation)]
100+
// No, there won't be more than 2^32-1 items in a list
100101
let len = match tile.page {
101102
Page::ClipboardHistory => tile.clipboard_content.len() as u32,
102103
Page::EmojiSearch => tile.emoji_apps.search_prefix(&tile.query_lc).count() as u32, // or tile.results.len()
@@ -154,11 +155,7 @@ pub fn handle_update(tile: &mut Tile, message: Message) -> Task<Message> {
154155
])
155156
}
156157

157-
Message::OpenFocused => match tile
158-
.results
159-
.get(tile.focus_id as usize)
160-
.map(|x| &x.data)
161-
{
158+
Message::OpenFocused => match tile.results.get(tile.focus_id as usize).map(|x| &x.data) {
162159
Some(AppData::Builtin {
163160
command: AppCommand::Function(func),
164161
..
@@ -177,8 +174,7 @@ pub fn handle_update(tile: &mut Tile, message: Message) -> Task<Message> {
177174
Message::ReloadConfig => {
178175
let new_config: Config = match toml::from_str(
179176
&fs::read_to_string(
180-
std::env::var("HOME").unwrap_or_default()
181-
+ "/.config/rustcast/config.toml",
177+
std::env::var("HOME").unwrap_or_default() + "/.config/rustcast/config.toml",
182178
)
183179
.unwrap_or_default(),
184180
) {
@@ -314,8 +310,7 @@ pub fn handle_update(tile: &mut Tile, message: Message) -> Task<Message> {
314310
if focused {
315311
Task::none()
316312
} else if cfg!(target_os = "macos") {
317-
Task::done(Message::HideWindow(wid))
318-
.chain(Task::done(Message::ClearSearchQuery))
313+
Task::done(Message::HideWindow(wid)).chain(Task::done(Message::ClearSearchQuery))
319314
} else {
320315
// linux seems to not wanna unfocus it on start making it not show
321316
Task::none()

src/calculator.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ pub enum BinOp {
4949

5050
impl Expr {
5151
pub fn eval(&self) -> Option<f64> {
52-
use BinOp::{Add, Sub, Mul, Div, Pow};
53-
use UnaryOp::{Plus, Minus};
52+
use BinOp::{Add, Div, Mul, Pow, Sub};
53+
use UnaryOp::{Minus, Plus};
5454
match self {
5555
Expr::Number(x) => Some(*x),
5656

@@ -151,7 +151,9 @@ impl<'a> Lexer<'a> {
151151

152152
fn next_token(&mut self) -> Result<Token, String> {
153153
self.skip_ws();
154-
let Some(c) = self.peek_char() else { return Ok(Token::End) };
154+
let Some(c) = self.peek_char() else {
155+
return Ok(Token::End);
156+
};
155157

156158
// single-char tokens
157159
let tok = match c {

src/cross_platform/windows/app_finding.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub fn get_apps_from_registry(apps: &mut Vec<App>) {
5757
let exe_string = exe_string.split(',').next().unwrap();
5858

5959
// make sure it ends with .exe
60-
if !exe_string.to_lowercase().ends_with(".exe"){
60+
if !exe_string.to_lowercase().ends_with(".exe") {
6161
return;
6262
}
6363

@@ -112,17 +112,16 @@ pub fn index_start_menu() -> Vec<App> {
112112
let target = x.link_target();
113113
let file_name = path.file_name().to_string_lossy().to_string();
114114

115-
if let Some(target) = target { Some(App::new_executable(
116-
&file_name,
117-
&file_name,
118-
"",
119-
PathBuf::from(target.clone()),
120-
None,
121-
)) } else {
122-
tracing::debug!(
123-
"Link at {} has no target, skipped",
124-
path.path().display()
125-
);
115+
if let Some(target) = target {
116+
Some(App::new_executable(
117+
&file_name,
118+
&file_name,
119+
"",
120+
PathBuf::from(target.clone()),
121+
None,
122+
))
123+
} else {
124+
tracing::debug!("Link at {} has no target, skipped", path.path().display());
126125
None
127126
}
128127
}

src/utils.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,9 @@ pub fn is_url_like(s: &str) -> bool {
241241
}
242242
let mut parts = s.split('.');
243243

244-
let Some(tld) = parts.next_back() else { return false };
244+
let Some(tld) = parts.next_back() else {
245+
return false;
246+
};
245247

246248
if tld.is_empty() || tld.len() > 63 || !tld.chars().all(|c| c.is_ascii_alphabetic()) {
247249
return false;

0 commit comments

Comments
 (0)