mirror of
https://github.com/ratatui-org/ratatui
synced 2024-11-14 00:47:14 +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"
|
instability = "0.3.1"
|
||||||
itertools = "0.13"
|
itertools = "0.13"
|
||||||
lru = "0.12.0"
|
lru = "0.12.0"
|
||||||
|
once_cell = "1.19.0"
|
||||||
paste = "1.0.2"
|
paste = "1.0.2"
|
||||||
palette = { version = "0.7.6", optional = true }
|
palette = { version = "0.7.6", optional = true }
|
||||||
serde = { version = "1", optional = true, features = ["derive"] }
|
serde = { version = "1", optional = true, features = ["derive"] }
|
||||||
|
|
|
@ -37,7 +37,7 @@ struct App {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl App {
|
impl App {
|
||||||
fn new(recorder_widget: RecorderWidget) -> Self {
|
const fn new(recorder_widget: RecorderWidget) -> Self {
|
||||||
Self {
|
Self {
|
||||||
should_quit: false,
|
should_quit: false,
|
||||||
recorder_widget,
|
recorder_widget,
|
||||||
|
@ -82,7 +82,7 @@ impl App {
|
||||||
|
|
||||||
fn on_key_press(&mut self, key: event::KeyEvent) {
|
fn on_key_press(&mut self, key: event::KeyEvent) {
|
||||||
match key.code {
|
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 p90 = Duration::from_secs_f64(summary.quantile(0.9).unwrap());
|
||||||
let p99 = Duration::from_secs_f64(summary.quantile(0.99).unwrap());
|
let p99 = Duration::from_secs_f64(summary.quantile(0.99).unwrap());
|
||||||
let line = format!(
|
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));
|
histograms.push((key.clone(), line));
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,9 +100,10 @@
|
||||||
//! [Backend Comparison]:
|
//! [Backend Comparison]:
|
||||||
//! https://ratatui.rs/concepts/backends/comparison/
|
//! https://ratatui.rs/concepts/backends/comparison/
|
||||||
//! [Ratatui Website]: https://ratatui.rs
|
//! [Ratatui Website]: https://ratatui.rs
|
||||||
use std::{io, sync::LazyLock};
|
use std::io;
|
||||||
|
|
||||||
use metrics::{Counter, Histogram};
|
use metrics::{Counter, Histogram};
|
||||||
|
use once_cell::sync::Lazy;
|
||||||
use strum::{Display, EnumString};
|
use strum::{Display, EnumString};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -129,7 +130,7 @@ pub use self::termwiz::TermwizBackend;
|
||||||
mod test;
|
mod test;
|
||||||
pub use self::test::TestBackend;
|
pub use self::test::TestBackend;
|
||||||
|
|
||||||
static METRICS: LazyLock<Metrics> = LazyLock::new(Metrics::new);
|
static METRICS: Lazy<Metrics> = Lazy::new(Metrics::new);
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct Metrics {
|
struct Metrics {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
use std::{
|
use std::{
|
||||||
fmt,
|
fmt,
|
||||||
ops::{Index, IndexMut},
|
ops::{Index, IndexMut},
|
||||||
sync::LazyLock,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use metrics::Histogram;
|
use metrics::Histogram;
|
||||||
|
use once_cell::sync::Lazy;
|
||||||
use unicode_segmentation::UnicodeSegmentation;
|
use unicode_segmentation::UnicodeSegmentation;
|
||||||
use unicode_width::UnicodeWidthStr;
|
use unicode_width::UnicodeWidthStr;
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ pub struct Buffer {
|
||||||
pub content: Vec<Cell>,
|
pub content: Vec<Cell>,
|
||||||
}
|
}
|
||||||
|
|
||||||
static METRICS: LazyLock<Metrics> = LazyLock::new(Metrics::new);
|
static METRICS: Lazy<Metrics> = Lazy::new(Metrics::new);
|
||||||
|
|
||||||
struct Metrics {
|
struct Metrics {
|
||||||
diff_duration: Histogram,
|
diff_duration: Histogram,
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use std::{io, sync::LazyLock};
|
use std::io;
|
||||||
|
|
||||||
use metrics::{Counter, Histogram};
|
use metrics::{Counter, Histogram};
|
||||||
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
backend::ClearType, buffer::Cell, counter, duration_histogram, metrics::HistogramExt,
|
backend::ClearType, buffer::Cell, counter, duration_histogram, metrics::HistogramExt,
|
||||||
|
@ -87,7 +88,7 @@ pub struct Options {
|
||||||
pub viewport: Viewport,
|
pub viewport: Viewport,
|
||||||
}
|
}
|
||||||
|
|
||||||
static METRICS: LazyLock<Metrics> = LazyLock::new(Metrics::new);
|
static METRICS: Lazy<Metrics> = Lazy::new(Metrics::new);
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct Metrics {
|
struct Metrics {
|
||||||
|
|
Loading…
Reference in a new issue