From 8681ec5cc9d024df6b0ae23542af60734f09478c Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Thu, 31 Mar 2022 21:10:02 +0200 Subject: [PATCH] small code cleanup --- egui_extras/src/strip.rs | 14 ++++---------- egui_extras/src/table.rs | 3 +-- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/egui_extras/src/strip.rs b/egui_extras/src/strip.rs index 131c55cb2..cdb44df09 100644 --- a/egui_extras/src/strip.rs +++ b/egui_extras/src/strip.rs @@ -117,6 +117,10 @@ pub struct Strip<'a, 'b> { impl<'a, 'b> Strip<'a, 'b> { fn next_cell_size(&mut self) -> (CellSize, CellSize) { + assert!( + !self.sizes.is_empty(), + "Tried using more strip cells than available." + ); let size = self.sizes[0]; self.sizes = &self.sizes[1..]; @@ -128,21 +132,11 @@ impl<'a, 'b> Strip<'a, 'b> { /// Add empty cell pub fn empty(&mut self) { - assert!( - !self.sizes.is_empty(), - "Tried using more strip cells than available." - ); - let (width, height) = self.next_cell_size(); self.layout.empty(width, height); } fn cell_impl(&mut self, clip: bool, add_contents: impl FnOnce(&mut Ui)) { - assert!( - !self.sizes.is_empty(), - "Tried using more strip cells than available." - ); - let (width, height) = self.next_cell_size(); self.layout.add(width, height, clip, add_contents); } diff --git a/egui_extras/src/table.rs b/egui_extras/src/table.rs index b105a886c..fd151680f 100644 --- a/egui_extras/src/table.rs +++ b/egui_extras/src/table.rs @@ -10,7 +10,6 @@ use crate::{ }; use egui::{Response, Ui}; -use std::cmp; /// Builder for a [`Table`] with (optional) fixed header and scrolling body. /// @@ -226,7 +225,7 @@ impl<'a> TableBody<'a> { let max_height = self.end_y - self.start_y; let count = (max_height / height).ceil() as usize; - let end = cmp::min(start + count, rows); + let end = rows.min(start + count); for idx in start..end { row(