Skip to content

Commit 35e2b35

Browse files
committed
Cargo fmt
1 parent 2d5f2b8 commit 35e2b35

File tree

8 files changed

+100
-45
lines changed

8 files changed

+100
-45
lines changed

objdiff-gui/src/app.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@ impl ObjectConfig {
147147
}
148148

149149
#[inline]
150-
fn bool_true() -> bool { true }
150+
fn bool_true() -> bool {
151+
true
152+
}
151153

152154
pub struct AppState {
153155
pub config: AppConfig,
@@ -442,10 +444,11 @@ impl AppState {
442444
let mut job = LayoutJob::default();
443445
job.append(context, 0.0, Default::default());
444446
job.append("\n", 0.0, Default::default());
445-
job.append(&format!("{e:#}"), 0.0, egui::TextFormat {
446-
color: egui::Color32::LIGHT_RED,
447-
..Default::default()
448-
});
447+
job.append(
448+
&format!("{e:#}"),
449+
0.0,
450+
egui::TextFormat { color: egui::Color32::LIGHT_RED, ..Default::default() },
451+
);
449452
self.top_left_toasts.error(job).closable(true).duration(None);
450453
}
451454
}

objdiff-gui/src/app_config.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ pub struct AppConfigVersion {
1919
}
2020

2121
impl Default for AppConfigVersion {
22-
fn default() -> Self { Self { version: 3 } }
22+
fn default() -> Self {
23+
Self { version: 3 }
24+
}
2325
}
2426

2527
/// Deserialize the AppConfig from storage, handling upgrades from older versions.
@@ -44,7 +46,9 @@ pub fn deserialize_config(storage: &dyn Storage) -> Option<AppConfig> {
4446
}
4547

4648
fn from_str<T>(str: &str) -> Option<T>
47-
where T: serde::de::DeserializeOwned {
49+
where
50+
T: serde::de::DeserializeOwned,
51+
{
4852
match ron::from_str(str) {
4953
Ok(config) => Some(config),
5054
Err(err) => {
@@ -292,7 +296,9 @@ impl DiffObjConfigV1 {
292296
}
293297

294298
#[inline]
295-
fn bool_true() -> bool { true }
299+
fn bool_true() -> bool {
300+
true
301+
}
296302

297303
#[derive(serde::Deserialize, serde::Serialize)]
298304
pub struct AppConfigV1 {

objdiff-gui/src/argp_version.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ use std::ffi::OsStr;
77
use argp::{EarlyExit, FromArgs, TopLevelCommand, parser::ParseGlobalOptions};
88

99
struct ArgsOrVersion<T>(T)
10-
where T: FromArgs;
10+
where
11+
T: FromArgs;
1112

1213
impl<T> TopLevelCommand for ArgsOrVersion<T> where T: FromArgs {}
1314

1415
impl<T> FromArgs for ArgsOrVersion<T>
15-
where T: FromArgs
16+
where
17+
T: FromArgs,
1618
{
1719
fn _from_args(
1820
command_name: &[&str],
@@ -58,6 +60,8 @@ where T: FromArgs
5860
/// This function will exit early from the current process if argument parsing was unsuccessful or if information like `--help` was requested.
5961
/// Error messages will be printed to stderr, and `--help` output to stdout.
6062
pub fn from_env<T>() -> T
61-
where T: TopLevelCommand {
63+
where
64+
T: TopLevelCommand,
65+
{
6266
argp::parse_args_or_exit::<ArgsOrVersion<T>>(argp::DEFAULT).0
6367
}

objdiff-gui/src/hotkeys.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ use egui::{
22
Context, Key, KeyboardShortcut, Modifiers, PointerButton, style::ScrollAnimation, vec2,
33
};
44

5-
fn any_widget_focused(ctx: &Context) -> bool { ctx.memory(|mem| mem.focused().is_some()) }
5+
fn any_widget_focused(ctx: &Context) -> bool {
6+
ctx.memory(|mem| mem.focused().is_some())
7+
}
68

79
pub fn enter_pressed(ctx: &Context) -> bool {
810
if any_widget_focused(ctx) {
@@ -40,13 +42,21 @@ pub fn down_pressed(ctx: &Context) -> bool {
4042
ctx.input_mut(|i| i.key_pressed(Key::ArrowDown) || i.key_pressed(Key::S))
4143
}
4244

43-
pub fn page_up_pressed(ctx: &Context) -> bool { ctx.input_mut(|i| i.key_pressed(Key::PageUp)) }
45+
pub fn page_up_pressed(ctx: &Context) -> bool {
46+
ctx.input_mut(|i| i.key_pressed(Key::PageUp))
47+
}
4448

45-
pub fn page_down_pressed(ctx: &Context) -> bool { ctx.input_mut(|i| i.key_pressed(Key::PageDown)) }
49+
pub fn page_down_pressed(ctx: &Context) -> bool {
50+
ctx.input_mut(|i| i.key_pressed(Key::PageDown))
51+
}
4652

47-
pub fn home_pressed(ctx: &Context) -> bool { ctx.input_mut(|i| i.key_pressed(Key::Home)) }
53+
pub fn home_pressed(ctx: &Context) -> bool {
54+
ctx.input_mut(|i| i.key_pressed(Key::Home))
55+
}
4856

49-
pub fn end_pressed(ctx: &Context) -> bool { ctx.input_mut(|i| i.key_pressed(Key::End)) }
57+
pub fn end_pressed(ctx: &Context) -> bool {
58+
ctx.input_mut(|i| i.key_pressed(Key::End))
59+
}
5060

5161
pub fn check_scroll_hotkeys(ui: &mut egui::Ui, include_small_increments: bool) {
5262
let ui_height = ui.available_rect_before_wrap().height();

objdiff-gui/src/jobs.rs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,18 @@ use crate::{
2020
struct EguiWaker(egui::Context);
2121

2222
impl Wake for EguiWaker {
23-
fn wake(self: Arc<Self>) { self.0.request_repaint(); }
23+
fn wake(self: Arc<Self>) {
24+
self.0.request_repaint();
25+
}
2426

25-
fn wake_by_ref(self: &Arc<Self>) { self.0.request_repaint(); }
27+
fn wake_by_ref(self: &Arc<Self>) {
28+
self.0.request_repaint();
29+
}
2630
}
2731

28-
pub fn egui_waker(ctx: &egui::Context) -> Waker { Waker::from(Arc::new(EguiWaker(ctx.clone()))) }
32+
pub fn egui_waker(ctx: &egui::Context) -> Waker {
33+
Waker::from(Arc::new(EguiWaker(ctx.clone())))
34+
}
2935

3036
pub fn is_create_scratch_available(config: &AppConfig) -> bool {
3137
let Some(selected_obj) = &config.selected_obj else {
@@ -127,10 +133,13 @@ pub fn start_build(ctx: &egui::Context, jobs: &mut JobQueue, config: objdiff::Ob
127133

128134
pub fn start_check_update(ctx: &egui::Context, jobs: &mut JobQueue) {
129135
jobs.push_once(Job::Update, || {
130-
jobs::check_update::start_check_update(egui_waker(ctx), CheckUpdateConfig {
131-
build_updater,
132-
bin_names: vec![BIN_NAME_NEW.to_string(), BIN_NAME_OLD.to_string()],
133-
})
136+
jobs::check_update::start_check_update(
137+
egui_waker(ctx),
138+
CheckUpdateConfig {
139+
build_updater,
140+
bin_names: vec![BIN_NAME_NEW.to_string(), BIN_NAME_OLD.to_string()],
141+
},
142+
)
134143
});
135144
}
136145

objdiff-gui/src/views/appearance.rs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,19 @@ impl Default for FontState {
9191
impl Appearance {
9292
pub fn pre_update(&mut self, ctx: &egui::Context) {
9393
let mut style = ctx.style().as_ref().clone();
94-
style.text_styles.insert(TextStyle::Body, FontId {
95-
size: (self.ui_font.size * 0.75).floor(),
96-
family: self.ui_font.family.clone(),
97-
});
94+
style.text_styles.insert(
95+
TextStyle::Body,
96+
FontId {
97+
size: (self.ui_font.size * 0.75).floor(),
98+
family: self.ui_font.family.clone(),
99+
},
100+
);
98101
style.text_styles.insert(TextStyle::Body, self.ui_font.clone());
99102
style.text_styles.insert(TextStyle::Button, self.ui_font.clone());
100-
style.text_styles.insert(TextStyle::Heading, FontId {
101-
size: (self.ui_font.size * 1.5).floor(),
102-
family: self.ui_font.family.clone(),
103-
});
103+
style.text_styles.insert(
104+
TextStyle::Heading,
105+
FontId { size: (self.ui_font.size * 1.5).floor(), family: self.ui_font.family.clone() },
106+
);
104107
style.text_styles.insert(TextStyle::Monospace, self.code_font.clone());
105108
match self.theme {
106109
egui::Theme::Dark => {

objdiff-gui/src/views/diff.rs

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ use objdiff_core::{
66
diff::{
77
DiffObjConfig, ObjectDiff, SymbolDiff,
88
data::BYTES_PER_ROW,
9-
display::{ContextItem, DiffText, HoverItem, HoverItemColor, SymbolFilter, SymbolNavigationKind, display_row},
9+
display::{
10+
ContextItem, DiffText, HoverItem, HoverItemColor, SymbolFilter, SymbolNavigationKind,
11+
display_row,
12+
},
1013
},
1114
obj::{InstructionArgValue, Object, Symbol},
1215
util::ReallySigned,
@@ -61,16 +64,25 @@ impl<'a> DiffColumnContext<'a> {
6164
}
6265

6366
#[inline]
64-
pub fn has_symbol(&self) -> bool { self.symbol.is_some() }
67+
pub fn has_symbol(&self) -> bool {
68+
self.symbol.is_some()
69+
}
6570

6671
#[inline]
67-
pub fn id(&self) -> Option<&str> { self.symbol.map(|(symbol, _, _)| symbol.name.as_str()) }
72+
pub fn id(&self) -> Option<&str> {
73+
self.symbol.map(|(symbol, _, _)| symbol.name.as_str())
74+
}
6875
}
6976

7077
/// Obtains the assembly text for a given symbol diff, suitable for copying to clipboard.
71-
fn get_asm_text(obj: &Object, symbol_diff: &SymbolDiff, symbol_idx: usize, diff_config: &DiffObjConfig) -> String {
78+
fn get_asm_text(
79+
obj: &Object,
80+
symbol_diff: &SymbolDiff,
81+
symbol_idx: usize,
82+
diff_config: &DiffObjConfig,
83+
) -> String {
7284
let mut asm_text = String::new();
73-
85+
7486
for ins_row in &symbol_diff.instruction_rows {
7587
let mut line = String::new();
7688
let result = display_row(obj, symbol_idx, ins_row, diff_config, |segment| {
@@ -97,13 +109,13 @@ fn get_asm_text(obj: &Object, symbol_diff: &SymbolDiff, symbol_idx: usize, diff_
97109
line.push_str(&text);
98110
Ok(())
99111
});
100-
112+
101113
if result.is_ok() {
102114
asm_text.push_str(&line);
103115
asm_text.push('\n');
104116
}
105117
}
106-
118+
107119
asm_text
108120
}
109121

@@ -255,15 +267,17 @@ pub fn diff_view_ui(
255267
if state.current_view == View::FunctionDiff
256268
&& ui
257269
.button("Change target")
258-
.on_hover_text_at_pointer("Choose a different symbol to use as the target")
270+
.on_hover_text_at_pointer(
271+
"Choose a different symbol to use as the target",
272+
)
259273
.clicked()
260274
|| hotkeys::consume_change_target_shortcut(ui.ctx())
261275
{
262276
if let Some(symbol_ref) = state.symbol_state.right_symbol.as_ref() {
263277
ret = Some(DiffViewAction::SelectingLeft(symbol_ref.clone()));
264278
}
265279
}
266-
280+
267281
// Copy target ASM button.
268282
if state.current_view == View::FunctionDiff {
269283
if let Some((_, symbol_diff, symbol_idx)) = left_ctx.symbol {
@@ -273,7 +287,8 @@ pub fn diff_view_ui(
273287
.on_hover_text_at_pointer("Copy assembly to clipboard")
274288
.clicked()
275289
{
276-
let asm_text = get_asm_text(obj, symbol_diff, symbol_idx, diff_config);
290+
let asm_text =
291+
get_asm_text(obj, symbol_diff, symbol_idx, diff_config);
277292
ui.ctx().copy_text(asm_text);
278293
}
279294
}
@@ -436,7 +451,7 @@ pub fn diff_view_ui(
436451
{
437452
ret = Some(DiffViewAction::SelectingRight(symbol_ref.clone()));
438453
}
439-
454+
440455
// Copy base ASM button.
441456
if let Some((_, symbol_diff, symbol_idx)) = right_ctx.symbol {
442457
if let Some((obj, _)) = right_ctx.obj {
@@ -445,7 +460,8 @@ pub fn diff_view_ui(
445460
.on_hover_text_at_pointer("Copy assembly to clipboard")
446461
.clicked()
447462
{
448-
let asm_text = get_asm_text(obj, symbol_diff, symbol_idx, diff_config);
463+
let asm_text =
464+
get_asm_text(obj, symbol_diff, symbol_idx, diff_config);
449465
ui.ctx().copy_text(asm_text);
450466
}
451467
}

objdiff-gui/src/views/frame_history.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,13 @@ impl FrameHistory {
4949
self.frame_times.add(now, previous_frame_time); // projected
5050
}
5151

52-
pub fn mean_frame_time(&self) -> f32 { self.frame_times.average().unwrap_or_default() }
52+
pub fn mean_frame_time(&self) -> f32 {
53+
self.frame_times.average().unwrap_or_default()
54+
}
5355

54-
pub fn fps(&self) -> f32 { 1.0 / self.frame_times.mean_time_interval().unwrap_or_default() }
56+
pub fn fps(&self) -> f32 {
57+
1.0 / self.frame_times.mean_time_interval().unwrap_or_default()
58+
}
5559

5660
pub fn ui(&mut self, ui: &mut egui::Ui) {
5761
ui.label(format!("Mean CPU usage: {:.2} ms / frame", 1e3 * self.mean_frame_time()))

0 commit comments

Comments
 (0)