Move egui::util::History to emath::History (#2329)

* Move egui::util::History to emath::History

It is a nice thing to use outside of egui,
and it is more math-related than gui-related.

* Fix doctest
This commit is contained in:
Emil Ernerfeldt 2022-11-21 14:14:33 +01:00 committed by GitHub
parent f4d8ab9779
commit 1c8cf9e3d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 4 deletions

View file

@ -2,11 +2,10 @@
pub mod cache;
pub(crate) mod fixed_cache;
mod history;
pub mod id_type_map;
pub mod undoer;
pub use history::History;
pub use id_type_map::IdTypeMap;
pub use epaint::emath::History;
pub use epaint::util::{hash, hash_with};

View file

@ -41,7 +41,7 @@ where
{
/// Example:
/// ```
/// # use egui::util::History;
/// # use emath::History;
/// # fn now() -> f64 { 0.0 }
/// // Drop events that are older than one second,
/// // as long we keep at least two events. Never keep more than a hundred events.
@ -125,7 +125,7 @@ where
/// Values must be added with a monotonically increasing time, or at least not decreasing.
pub fn add(&mut self, now: f64, value: T) {
if let Some((last_time, _)) = self.values.back() {
crate::egui_assert!(now >= *last_time, "Time shouldn't move backwards");
crate::emath_assert!(now >= *last_time, "Time shouldn't move backwards");
}
self.total_count += 1;
self.values.push_back((now, value));

View file

@ -27,6 +27,7 @@ use std::ops::{Add, Div, Mul, RangeInclusive, Sub};
// ----------------------------------------------------------------------------
pub mod align;
mod history;
mod numeric;
mod pos2;
mod rect;
@ -37,6 +38,7 @@ mod vec2;
pub use {
align::{Align, Align2},
history::History,
numeric::*,
pos2::*,
rect::*,