Skip to content

Commit

Permalink
refactor: destruct tuples to enhance readability
Browse files Browse the repository at this point in the history
  • Loading branch information
Integral-Tech committed Nov 18, 2024
1 parent 6746ba6 commit e4726b4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
8 changes: 4 additions & 4 deletions tunet-gui/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,8 @@ fn draw_daily(
let (width, height) = ((width * scale) as u32, (height * scale) as u32);
let text_color = RGBColor(text_color.red(), text_color.green(), text_color.blue());

let date_range = (details.now.with_day(1).unwrap(), details.now);
let flux_range = (0, details.max_flux.0);
let (date_start, date_end) = (details.now.with_day(1).unwrap(), details.now);
let (flux_start, Flux(flux_end)) = (0, details.max_flux);

let mut buffer = String::new();
let backend = SVGBackend::with_string(&mut buffer, (width, height));
Expand All @@ -301,8 +301,8 @@ fn draw_daily(
.margin_top(10.0 * scale)
.margin_right(20.0 * scale)
.build_cartesian_2d(
RangedDate::from(date_range.0..date_range.1),
flux_range.0..flux_range.1,
RangedDate::from(date_start..date_end),
flux_start..flux_end,
)?;
chart
.configure_mesh()
Expand Down
7 changes: 3 additions & 4 deletions tunet/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ use std::net::Ipv4Addr;
use tunet_helper::{usereg::*, *};
use tunet_settings::*;

fn get_flux_color(f: &Flux, total: bool) -> Color {
let flux = f.0;
fn get_flux_color(&Flux(flux): &Flux, total: bool) -> Color {
if flux == 0 {
Color::Cyan
} else if flux < if total { 20_000_000_000 } else { 2_000_000_000 } {
Expand Down Expand Up @@ -317,8 +316,8 @@ impl Detail {
}
if self.nuon {
print!("[[login_time flux]; ");
for (date, flux) in details {
print!("[{} {}b] ", date, flux.0);
for (date, Flux(flux)) in details {
print!("[{} {}b] ", date, flux);
}
println!("]");
} else {
Expand Down

0 comments on commit e4726b4

Please sign in to comment.