Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

style(recording): use inline format strings in examples

Richie McIlroyc5cabc65b90c
diff --git a/crates/recording/examples/camera-lifecycle-stress.rs b/crates/recording/examples/camera-lifecycle-stress.rs
index 5c49024d3..ce9279374 100644
--- a/crates/recording/examples/camera-lifecycle-stress.rs
+++ b/crates/recording/examples/camera-lifecycle-stress.rs
@@ -105,13 +105,13 @@ impl Tracker {
println!(" Start memory: {:>6.1} MB", first.memory_mb);
println!(" End memory: {:>6.1} MB", last.memory_mb);
- println!(" Peak memory: {:>6.1} MB", peak);
+ println!(" Peak memory: {peak:>6.1} MB");
println!(
" Net growth: {:>+6.1} MB",
last.memory_mb - first.memory_mb
);
- println!(" Peak threads: {}", peak_threads);
- println!(" Final threads: {}", end_threads);
+ println!(" Peak threads: {peak_threads}");
+ println!(" Final threads: {end_threads}");
let cycle_starts: Vec<&Snapshot> = self
.snapshots
@@ -125,16 +125,13 @@ impl Tracker {
let per_cycle = growth_first_to_last / (cycle_starts.len() as f64 - 1.0);
println!("\n Per-cycle analysis ({} cycles):", cycle_starts.len());
- println!(" Growth across cycles: {:>+.1} MB", growth_first_to_last);
- println!(" Avg per cycle: {:>+.2} MB", per_cycle);
+ println!(" Growth across cycles: {growth_first_to_last:>+.1} MB");
+ println!(" Avg per cycle: {per_cycle:>+.2} MB");
if per_cycle > 5.0 {
- println!(
- "\n *** MEMORY LEAK DETECTED: {:>+.1} MB/cycle ***",
- per_cycle
- );
+ println!("\n *** MEMORY LEAK DETECTED: {per_cycle:>+.1} MB/cycle ***");
} else if per_cycle > 1.0 {
- println!("\n *** POTENTIAL LEAK: {:>+.1} MB/cycle ***", per_cycle);
+ println!("\n *** POTENTIAL LEAK: {per_cycle:>+.1} MB/cycle ***");
} else {
println!("\n [OK] Memory stable across cycles (< 1 MB/cycle)");
}
@@ -152,8 +149,7 @@ impl Tracker {
if thread_growth > 2 {
println!(
- " *** THREAD LEAK: {} threads accumulated across cycles ***",
- thread_growth
+ " *** THREAD LEAK: {thread_growth} threads accumulated across cycles ***"
);
} else {
println!(" [OK] Thread count stable across cycles");
@@ -169,10 +165,7 @@ async fn run_lifecycle_stress(
) -> Result<(), Box<dyn std::error::Error>> {
println!("\n{}", "=".repeat(72));
println!(" CAMERA FEED LIFECYCLE STRESS TEST");
- println!(
- " {} cycles x {}s active + {}s paused",
- cycles, run_secs, pause_secs
- );
+ println!(" {cycles} cycles x {run_secs}s active + {pause_secs}s paused");
println!("{}\n", "=".repeat(72));
let mut tracker = Tracker::new();
@@ -224,10 +217,7 @@ async fn run_lifecycle_stress(
}
let fps = received as f64 / run_secs as f64;
- println!(
- " Received {} frames ({:.1} FPS) over {}s",
- received, fps, run_secs
- );
+ println!(" Received {received} frames ({fps:.1} FPS) over {run_secs}s");
if received == 0 {
println!(" *** WARNING: Zero frames received! Camera may be stuck. ***");
@@ -242,18 +232,15 @@ async fn run_lifecycle_stress(
let remove_ms = remove_start.elapsed().as_millis();
if remove_ms > 2000 {
- println!(
- " *** WARNING: RemoveInput took {}ms (>2s) ***",
- remove_ms
- );
+ println!(" *** WARNING: RemoveInput took {remove_ms}ms (>2s) ***");
} else {
- println!(" RemoveInput took {}ms", remove_ms);
+ println!(" RemoveInput took {remove_ms}ms");
}
tracker.snap(&format!("Cycle {cycle}: after RemoveInput"));
if pause_secs > 0 && cycle < cycles {
- println!(" Pausing {}s...", pause_secs);
+ println!(" Pausing {pause_secs}s...");
tokio::time::sleep(Duration::from_secs(pause_secs)).await;
tracker.snap(&format!("Cycle {cycle}: after pause"));
}
@@ -269,7 +256,7 @@ async fn run_lifecycle_stress(
async fn run_rapid_toggle(toggles: usize) -> Result<(), Box<dyn std::error::Error>> {
println!("\n{}", "=".repeat(72));
- println!(" RAPID CAMERA TOGGLE TEST ({} toggles)", toggles);
+ println!(" RAPID CAMERA TOGGLE TEST ({toggles} toggles)");
println!("{}\n", "=".repeat(72));
let mut tracker = Tracker::new();
@@ -322,7 +309,7 @@ async fn run_rapid_toggle(toggles: usize) -> Result<(), Box<dyn std::error::Erro
async fn run_setinput_after_unlock(cycles: usize) -> Result<(), Box<dyn std::error::Error>> {
println!("\n{}", "=".repeat(72));
- println!(" SETINPUT AFTER UNLOCK TEST ({} cycles)", cycles);
+ println!(" SETINPUT AFTER UNLOCK TEST ({cycles} cycles)");
println!(" (Simulates: record → stop → reopen camera)");
println!("{}\n", "=".repeat(72));
@@ -384,16 +371,13 @@ async fn run_setinput_after_unlock(cycles: usize) -> Result<(), Box<dyn std::err
match result {
Ok(Ok(_)) => {
let ms = setinput_start.elapsed().as_millis();
- println!(" SetInput after Unlock: OK ({}ms)", ms);
+ println!(" SetInput after Unlock: OK ({ms}ms)");
if ms > 3000 {
- println!(
- " *** WARNING: SetInput took {}ms (>3s), possible blocking ***",
- ms
- );
+ println!(" *** WARNING: SetInput took {ms}ms (>3s), possible blocking ***");
}
}
Ok(Err(e)) => {
- println!(" *** SetInput after Unlock FAILED: {} ***", e);
+ println!(" *** SetInput after Unlock FAILED: {e} ***");
}
Err(_) => {
println!(" *** TIMEOUT: SetInput blocked for >10s after Unlock! ***");
diff --git a/crates/recording/examples/camera-preview-benchmark.rs b/crates/recording/examples/camera-preview-benchmark.rs
index dbc4bc486..a4052fdb1 100644
--- a/crates/recording/examples/camera-preview-benchmark.rs
+++ b/crates/recording/examples/camera-preview-benchmark.rs
@@ -373,10 +373,7 @@ async fn run_camera_capture(duration_secs: u64) -> Vec<FFmpegVideoFrame> {
async fn profile_live_preview(duration_secs: u64, output_width: u32) {
println!("\n{}", "=".repeat(60));
- println!(
- " LIVE CAMERA PREVIEW PROFILE ({}px, {duration_secs}s)",
- output_width
- );
+ println!(" LIVE CAMERA PREVIEW PROFILE ({output_width}px, {duration_secs}s)");
println!("{}\n", "=".repeat(60));
let mut cpu = CpuTracker::new();
@@ -608,7 +605,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
simulate_ws_preview_optimized(&frames, "WS OPTIMIZED (640, reuse buffers)");
println!("\n{}", "=".repeat(60));
- println!(" LIVE PREVIEW CPU PROFILE ({}s per resolution)", duration);
+ println!(" LIVE PREVIEW CPU PROFILE ({duration}s per resolution)");
println!("{}", "=".repeat(60));
profile_live_preview(duration, 1280).await;
diff --git a/crates/recording/examples/playback-test-runner.rs b/crates/recording/examples/playback-test-runner.rs
index 7165e8330..7acb9cccb 100644
--- a/crates/recording/examples/playback-test-runner.rs
+++ b/crates/recording/examples/playback-test-runner.rs
@@ -979,7 +979,7 @@ fn report_to_markdown(report: &RecordingTestReport) -> String {
hw_str
));
if let Some(reason) = &result.fallback_reason {
- md.push_str(&format!("| ↳ Fallback | ⚠️ | {} |\n", reason));
+ md.push_str(&format!("| ↳ Fallback | ⚠️ | {reason} |\n"));
}
}
@@ -1082,8 +1082,8 @@ fn generate_benchmark_markdown(
let timestamp = Utc::now().format("%Y-%m-%d %H:%M:%S UTC").to_string();
let local_timestamp = Local::now().format("%Y-%m-%d %H:%M:%S").to_string();
- md.push_str(&format!("### Benchmark Run: {}\n\n", timestamp));
- md.push_str(&format!("*Local time: {}*\n\n", local_timestamp));
+ md.push_str(&format!("### Benchmark Run: {timestamp}\n\n"));
+ md.push_str(&format!("*Local time: {local_timestamp}*\n\n"));
let passed = reports.iter().filter(|r| r.overall_passed).count();
let total = reports.len();
@@ -1094,15 +1094,14 @@ fn generate_benchmark_markdown(
};
md.push_str(&format!(
- "**Overall Result:** {} ({}/{})\n\n",
- overall_status, passed, total
+ "**Overall Result:** {overall_status} ({passed}/{total})\n\n"
));
if let Some(notes_text) = notes {
- md.push_str(&format!("**Notes:** {}\n\n", notes_text));
+ md.push_str(&format!("**Notes:** {notes_text}\n\n"));
}
- md.push_str(&format!("**Command:** `{}`\n\n", command));
+ md.push_str(&format!("**Command:** `{command}`\n\n"));
md.push_str("<details>\n<summary>System Information</summary>\n\n");
let sys_info = SystemInfo::collect();
diff --git a/crates/recording/examples/real-device-test-runner.rs b/crates/recording/examples/real-device-test-runner.rs
index f90dbb4c5..e1a91e28d 100644
--- a/crates/recording/examples/real-device-test-runner.rs
+++ b/crates/recording/examples/real-device-test-runner.rs
@@ -1954,14 +1954,12 @@ fn report_to_markdown(report: &TestReport) -> String {
}
if !seg.jitter_ok {
md.push_str(&format!(
- "| | ⚠️ | Jitter exceeds {}ms |\n",
- JITTER_TOLERANCE_MS
+ "| | ⚠️ | Jitter exceeds {JITTER_TOLERANCE_MS}ms |\n"
));
}
if !seg.dropped_ok {
md.push_str(&format!(
- "| | ⚠️ | Dropped frames exceed {}% |\n",
- MAX_DROPPED_FRAME_PERCENT
+ "| | ⚠️ | Dropped frames exceed {MAX_DROPPED_FRAME_PERCENT}% |\n"
));
}
}
@@ -2056,8 +2054,8 @@ fn generate_benchmark_markdown(
let timestamp = Utc::now().format("%Y-%m-%d %H:%M:%S UTC").to_string();
let local_timestamp = Local::now().format("%Y-%m-%d %H:%M:%S").to_string();
- md.push_str(&format!("### Benchmark Run: {}\n\n", timestamp));
- md.push_str(&format!("*Local time: {}*\n\n", local_timestamp));
+ md.push_str(&format!("### Benchmark Run: {timestamp}\n\n"));
+ md.push_str(&format!("*Local time: {local_timestamp}*\n\n"));
let passed = reports.iter().filter(|r| r.passed).count();
let total = reports.len();
@@ -2068,15 +2066,14 @@ fn generate_benchmark_markdown(
};
md.push_str(&format!(
- "**Overall Result:** {} ({}/{})\n\n",
- overall_status, passed, total
+ "**Overall Result:** {overall_status} ({passed}/{total})\n\n"
));
if let Some(notes_text) = notes {
- md.push_str(&format!("**Notes:** {}\n\n", notes_text));
+ md.push_str(&format!("**Notes:** {notes_text}\n\n"));
}
- md.push_str(&format!("**Command:** `{}`\n\n", command));
+ md.push_str(&format!("**Command:** `{command}`\n\n"));
md.push_str("<details>\n<summary>System Information</summary>\n\n");
let sys_info = SystemInfo::collect(devices);