mirror of
https://github.com/ratatui-org/ratatui
synced 2024-11-10 07:04:17 +00:00
fix: use once_cell::lazy instead of LazyLock to avoid MSRV 1.80
Fix ordering of histogram lines in metrics example Fix clippy lints
This commit is contained in:
parent
3b132e2768
commit
b5f2c0cef3
5 changed files with 12 additions and 9 deletions
|
@ -30,6 +30,7 @@ document-features = { version = "0.2.7", optional = true }
|
|||
instability = "0.3.1"
|
||||
itertools = "0.13"
|
||||
lru = "0.12.0"
|
||||
once_cell = "1.19.0"
|
||||
paste = "1.0.2"
|
||||
palette = { version = "0.7.6", optional = true }
|
||||
serde = { version = "1", optional = true, features = ["derive"] }
|
||||
|
|
|
@ -37,7 +37,7 @@ struct App {
|
|||
}
|
||||
|
||||
impl App {
|
||||
fn new(recorder_widget: RecorderWidget) -> Self {
|
||||
const fn new(recorder_widget: RecorderWidget) -> Self {
|
||||
Self {
|
||||
should_quit: false,
|
||||
recorder_widget,
|
||||
|
@ -82,7 +82,7 @@ impl App {
|
|||
|
||||
fn on_key_press(&mut self, key: event::KeyEvent) {
|
||||
match key.code {
|
||||
KeyCode::Char('q') => self.should_quit = true,
|
||||
KeyCode::Char('q') | KeyCode::Esc => self.should_quit = true,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ impl Widget for &RecorderWidget {
|
|||
let p90 = Duration::from_secs_f64(summary.quantile(0.9).unwrap());
|
||||
let p99 = Duration::from_secs_f64(summary.quantile(0.99).unwrap());
|
||||
let line = format!(
|
||||
"min:{min:>9.2?} max:{max:>9.2?} p50:{p50:>9.2?} p90:{p90:>9.2?} p99:{p99:>9.2?}"
|
||||
"min:{min:>9.2?} p50:{p50:>9.2?} p90:{p90:>9.2?} p99:{p99:>9.2?} max:{max:>9.2?}"
|
||||
);
|
||||
histograms.push((key.clone(), line));
|
||||
}
|
||||
|
|
|
@ -100,9 +100,10 @@
|
|||
//! [Backend Comparison]:
|
||||
//! https://ratatui.rs/concepts/backends/comparison/
|
||||
//! [Ratatui Website]: https://ratatui.rs
|
||||
use std::{io, sync::LazyLock};
|
||||
use std::io;
|
||||
|
||||
use metrics::{Counter, Histogram};
|
||||
use once_cell::sync::Lazy;
|
||||
use strum::{Display, EnumString};
|
||||
|
||||
use crate::{
|
||||
|
@ -129,7 +130,7 @@ pub use self::termwiz::TermwizBackend;
|
|||
mod test;
|
||||
pub use self::test::TestBackend;
|
||||
|
||||
static METRICS: LazyLock<Metrics> = LazyLock::new(Metrics::new);
|
||||
static METRICS: Lazy<Metrics> = Lazy::new(Metrics::new);
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Metrics {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
use std::{
|
||||
fmt,
|
||||
ops::{Index, IndexMut},
|
||||
sync::LazyLock,
|
||||
};
|
||||
|
||||
use metrics::Histogram;
|
||||
use once_cell::sync::Lazy;
|
||||
use unicode_segmentation::UnicodeSegmentation;
|
||||
use unicode_width::UnicodeWidthStr;
|
||||
|
||||
|
@ -74,7 +74,7 @@ pub struct Buffer {
|
|||
pub content: Vec<Cell>,
|
||||
}
|
||||
|
||||
static METRICS: LazyLock<Metrics> = LazyLock::new(Metrics::new);
|
||||
static METRICS: Lazy<Metrics> = Lazy::new(Metrics::new);
|
||||
|
||||
struct Metrics {
|
||||
diff_duration: Histogram,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use std::{io, sync::LazyLock};
|
||||
use std::io;
|
||||
|
||||
use metrics::{Counter, Histogram};
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
use crate::{
|
||||
backend::ClearType, buffer::Cell, counter, duration_histogram, metrics::HistogramExt,
|
||||
|
@ -87,7 +88,7 @@ pub struct Options {
|
|||
pub viewport: Viewport,
|
||||
}
|
||||
|
||||
static METRICS: LazyLock<Metrics> = LazyLock::new(Metrics::new);
|
||||
static METRICS: Lazy<Metrics> = Lazy::new(Metrics::new);
|
||||
|
||||
#[derive(Debug)]
|
||||
struct Metrics {
|
||||
|
|
Loading…
Reference in a new issue