diff options
author | ClementTsang <cjhtsang@uwaterloo.ca> | 2022-04-26 17:28:05 -0400 |
---|---|---|
committer | ClementTsang <cjhtsang@uwaterloo.ca> | 2022-04-28 01:40:10 -0400 |
commit | f68acc5c9d5f58f0ee56d1cacc1d8f0cc9c84616 (patch) | |
tree | dbdddbbddb7236f75ba820883b301276170f8064 /src/canvas/widgets/cpu_basic.rs | |
parent | b9a356f58128608418fc4dfe270e367e08e8582d (diff) |
refactor: remove trait usage in component drawing
When I was newer to Rust, I got the weird impression that you couldn't
add functionality to a struct outside of the defining file without using
a trait.
That's obviously not true, so it's high time I got rid of it and just
made it part of the impl of the class itself, rather than declaring a
trait and then exporting/importing it.
Diffstat (limited to 'src/canvas/widgets/cpu_basic.rs')
-rw-r--r-- | src/canvas/widgets/cpu_basic.rs | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/src/canvas/widgets/cpu_basic.rs b/src/canvas/widgets/cpu_basic.rs index 089502ec..aef2187b 100644 --- a/src/canvas/widgets/cpu_basic.rs +++ b/src/canvas/widgets/cpu_basic.rs @@ -15,14 +15,8 @@ use tui::{ widgets::{Block, Paragraph}, }; -pub trait CpuBasicWidget { - fn draw_basic_cpu<B: Backend>( - &self, f: &mut Frame<'_, B>, app_state: &mut App, draw_loc: Rect, widget_id: u64, - ); -} - -impl CpuBasicWidget for Painter { - fn draw_basic_cpu<B: Backend>( +impl Painter { + pub fn draw_basic_cpu<B: Backend>( &self, f: &mut Frame<'_, B>, app_state: &mut App, draw_loc: Rect, widget_id: u64, ) { // Skip the first element, it's the "all" element |