| 1 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::{ |
| 2 | borrowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/::Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#, |
| 3 | timerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/::{Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#, Instantrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/Instant#}, |
| 4 | }; |
| 5 | |
| 6 | use ratatuirust-analyzer cargo ratatui 0.30.2 crate/::{Framerust-analyzer cargo ratatui-core 0.1.2 terminal/frame/Frame#, layoutrust-analyzer cargo ratatui-core 0.1.2 layout/::Rectrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#}; |
| 7 | use timelessrust-analyzer cargo timeless 0.1.0 crate/::datarust-analyzer cargo timeless 0.1.0 data/::ChunkedDatarust-analyzer cargo timeless 0.1.0 data/chunked/ChunkedData#; |
| 8 | |
| 9 | use superrust-analyzer cargo bottom 0.14.9 components/time_series/::{ |
| 10 | AxisBoundrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/vendored/AxisBound#, ChartScalingrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/vendored/ChartScaling#, GraphDatarust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/GraphData#, GraphDrawCtxrust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#, TimeGraphrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/TimeGraph#, TimeseriesConfigrust-analyzer cargo bottom 0.14.9 components/time_series/TimeseriesConfig#, TimeseriesStaterust-analyzer cargo bottom 0.14.9 components/time_series/TimeseriesState#, |
| 11 | }; |
| 12 | |
| 13 | struct GraphHeightCacheInnerrust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/GraphHeightCacheInner# { |
| 14 | best_pointrust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/GraphHeightCacheInner#best_point.: (Instantrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/Instant#, f64), |
| 15 | right_edgerust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/GraphHeightCacheInner#right_edge.: Instantrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/Instant#, |
| 16 | periodrust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/GraphHeightCacheInner#period.: u64, |
| 17 | } |
| 18 | |
| 19 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:)] |
| 20 | pub struct GraphHeightCacherust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/GraphHeightCache# { |
| 21 | innerrust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/GraphHeightCache#inner.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<GraphHeightCacheInnerrust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/GraphHeightCacheInner#>, |
| 22 | } |
| 23 | |
| 24 | impl GraphHeightCacherust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/GraphHeightCache# { |
| 25 | /// Get the cached height if it exists, or update it otherwise. |
| 26 | pub(craterust-analyzer cargo bottom 0.14.9 crate/) fn get_or_updaterust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/impl#[GraphHeightCache]get_or_update().< |
| 27 | 'a, |
| 28 | F: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<f64> + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# + Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy# + 'a, |
| 29 | S: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = &'a ChunkedDatarust-analyzer cargo timeless 0.1.0 data/chunked/ChunkedData#<F>>, |
| 30 | >( |
| 31 | &mut self, last_time: &Instantrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/Instant#, current_display_time: u64, sources: S, times: &[Instantrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/Instant#], |
| 32 | ) -> f64 { |
| 33 | let visible_duration = Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#::from_millisrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]from_millis().(current_display_time); |
| 34 | |
| 35 | let (mut biggest, mut biggest_time, oldest_to_check) = if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(GraphHeightCacheInnerrust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/GraphHeightCacheInner# { |
| 36 | best_pointrust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/GraphHeightCacheInner#best_point., |
| 37 | right_edgerust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/GraphHeightCacheInner#right_edge., |
| 38 | periodrust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/GraphHeightCacheInner#period., |
| 39 | }) = self.innerrust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/GraphHeightCache#inner..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().() |
| 40 | && *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().period rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u64][`PartialEq<Self>`]eq().current_display_time |
| 41 | && last_time.duration_sincerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[Instant]duration_since().(best_point.0) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#lt().visible_duration |
| 42 | { |
| 43 | (best_point.1, best_point.0, *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().right_edge) |
| 44 | } else { |
| 45 | let visible_duration = Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#::from_millisrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/impl#[Duration]from_millis().(current_display_time); |
| 46 | |
| 47 | let visible_left_bound = match last_time.checked_subrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[Instant]checked_sub().(visible_duration) { |
| 48 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(v) => v, |
| 49 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => { |
| 50 | // On some systems (like Windows) it can be possible that the |
| 51 | // current display time causes subtraction to fail if, for example, |
| 52 | // the uptime of the system is too low and current_display_time is |
| 53 | // too high. See https://github.com/ClementTsang/bottom/issues/1825. |
| 54 | // |
| 55 | // As such, we instead take the oldest visible time. This is a bit |
| 56 | // inefficient, but since it should only happen rarely, it's fine. |
| 57 | times |
| 58 | .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 59 | .take_whilerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take_while().(|t| last_time.duration_sincerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[Instant]duration_since().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().t) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#lt().visible_duration) |
| 60 | .lastrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#last().() |
| 61 | .clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<&T>`]cloned().() |
| 62 | .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().last_time) |
| 63 | } |
| 64 | }; |
| 65 | |
| 66 | (0.0, visible_left_bound, visible_left_bound) |
| 67 | }; |
| 68 | |
| 69 | for source in sources { |
| 70 | for (&time, &v) in source |
| 71 | .iter_along_baserust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]iter_along_base().(times) |
| 72 | .revrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#rev().() |
| 73 | .take_whilerust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#take_while().(|&(&time, _)| time rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#ge().oldest_to_check) |
| 74 | { |
| 75 | let v = v.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#into().(); |
| 76 | if v rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]gt().biggest { |
| 77 | biggest = v; |
| 78 | biggest_time = time; |
| 79 | } |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | self.innerrust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/GraphHeightCache#inner. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(GraphHeightCacheInnerrust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/GraphHeightCacheInner# { |
| 84 | best_pointrust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/GraphHeightCacheInner#best_point.: (biggest_time, biggest), |
| 85 | right_edgerust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/GraphHeightCacheInner#right_edge.: *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().last_time, |
| 86 | periodrust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/GraphHeightCacheInner#period.: current_display_time, |
| 87 | }); |
| 88 | |
| 89 | biggest |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | /// A time series graph that automatically adjusts the y-axis based on the data provided. |
| 94 | pub struct AutoYAxisTimeGraphrust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/AutoYAxisTimeGraph# { |
| 95 | staterust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/AutoYAxisTimeGraph#state.: TimeseriesStaterust-analyzer cargo bottom 0.14.9 components/time_series/TimeseriesState#, |
| 96 | height_cacherust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/AutoYAxisTimeGraph#height_cache.: GraphHeightCacherust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/GraphHeightCache#, |
| 97 | } |
| 98 | |
| 99 | impl AutoYAxisTimeGraphrust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/AutoYAxisTimeGraph# { |
| 100 | pub(craterust-analyzer cargo bottom 0.14.9 crate/) fn newrust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/impl#[AutoYAxisTimeGraph]new().(config: TimeseriesConfigrust-analyzer cargo bottom 0.14.9 components/time_series/TimeseriesConfig#, autohide_timer: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Instantrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/Instant#>) -> Selfrust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/impl#[AutoYAxisTimeGraph] { |
| 101 | AutoYAxisTimeGraphrust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/AutoYAxisTimeGraph# { |
| 102 | staterust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/AutoYAxisTimeGraph#state.: TimeseriesStaterust-analyzer cargo bottom 0.14.9 components/time_series/TimeseriesState#::newrust-analyzer cargo bottom 0.14.9 components/time_series/impl#[TimeseriesState]new().(config, autohide_timer), |
| 103 | height_cacherust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/AutoYAxisTimeGraph#height_cache.: GraphHeightCacherust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/GraphHeightCache#::defaultrust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/impl#[GraphHeightCache][Default]default().(), |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | pub(craterust-analyzer cargo bottom 0.14.9 crate/) fn state_mutrust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/impl#[AutoYAxisTimeGraph]state_mut().(&mut self) -> &mut TimeseriesStaterust-analyzer cargo bottom 0.14.9 components/time_series/TimeseriesState# { |
| 108 | &mut self.staterust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/AutoYAxisTimeGraph#state. |
| 109 | } |
| 110 | |
| 111 | pub(craterust-analyzer cargo bottom 0.14.9 crate/) fn y_maxrust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/impl#[AutoYAxisTimeGraph]y_max().<'a, F, S>(&mut self, sources: S, times: &[Instantrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/Instant#]) -> f64 |
| 112 | where |
| 113 | F: Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<f64> + Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone# + Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy# + 'a, |
| 114 | S: Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#<Itemrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#Item# = &'a ChunkedDatarust-analyzer cargo timeless 0.1.0 data/chunked/ChunkedData#<F>>, |
| 115 | { |
| 116 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(last_time) = times.lastrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]last().() { |
| 117 | self.height_cacherust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/AutoYAxisTimeGraph#height_cache..get_or_updaterust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/impl#[GraphHeightCache]get_or_update().( |
| 118 | last_time, |
| 119 | self.staterust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/AutoYAxisTimeGraph#state..current_display_timerust-analyzer cargo bottom 0.14.9 components/time_series/impl#[TimeseriesState]current_display_time().(), |
| 120 | sources, |
| 121 | times, |
| 122 | ) |
| 123 | } else { |
| 124 | 0.0 |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | pub(craterust-analyzer cargo bottom 0.14.9 crate/) fn drawrust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/impl#[AutoYAxisTimeGraph]draw().<F: Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy# + Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default# + Intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/Into#<f64>>( |
| 129 | &self, f: &mut Framerust-analyzer cargo ratatui-core 0.1.2 terminal/frame/Frame#<'_>, draw_loc: Rectrust-analyzer cargo ratatui-core 0.1.2 layout/rect/Rect#, ctx: GraphDrawCtxrust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#<'_>, y_bounds: AxisBoundrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/vendored/AxisBound#, |
| 130 | y_labels: &[Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#<'_, str>], scaling: ChartScalingrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/vendored/ChartScaling#, data: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<GraphDatarust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/GraphData#<'_, F>>, |
| 131 | ) { |
| 132 | TimeGraphrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/TimeGraph# { |
| 133 | x_minrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/TimeGraph#x_min.: -rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[f64][Neg]neg().(self.staterust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/AutoYAxisTimeGraph#state..current_display_timerust-analyzer cargo bottom 0.14.9 components/time_series/impl#[TimeseriesState]current_display_time().() as f64), |
| 134 | hide_x_labelsrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/TimeGraph#hide_x_labels.: ctx.hide_x_labelsrust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#hide_x_labels., |
| 135 | y_boundsrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/TimeGraph#y_bounds., |
| 136 | y_labelsrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/TimeGraph#y_labels., |
| 137 | graph_stylerust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/TimeGraph#graph_style.: ctx.graph_stylerust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#graph_style., |
| 138 | general_widget_stylerust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/TimeGraph#general_widget_style.: ctx.general_widget_stylerust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#general_widget_style., |
| 139 | border_stylerust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/TimeGraph#border_style.: ctx.border_stylerust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#border_style., |
| 140 | border_typerust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/TimeGraph#border_type.: ctx.border_typerust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#border_type., |
| 141 | titlerust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/TimeGraph#title.: ctx.titlerust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#title., |
| 142 | is_selectedrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/TimeGraph#is_selected.: ctx.is_selectedrust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#is_selected., |
| 143 | is_expandedrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/TimeGraph#is_expanded.: ctx.is_expandedrust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#is_expanded., |
| 144 | title_stylerust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/TimeGraph#title_style.: ctx.title_stylerust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#title_style., |
| 145 | legend_positionrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/TimeGraph#legend_position.: ctx.legend_positionrust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#legend_position., |
| 146 | legend_constraintsrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/TimeGraph#legend_constraints.: ctx.legend_constraintsrust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#legend_constraints., |
| 147 | markerrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/TimeGraph#marker.: ctx.markerrust-analyzer cargo bottom 0.14.9 components/time_series/GraphDrawCtx#marker., |
| 148 | scalingrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/TimeGraph#scaling., |
| 149 | } |
| 150 | .drawrust-analyzer cargo bottom 0.14.9 canvas/components/time_series/base/impl#[`TimeGraph<'_>`]draw().(f, draw_loc, data) |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | #[cfg(test)] |
| 155 | mod testsrust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/tests/ { |
| 156 | use superrust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/::*; |
| 157 | |
| 158 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 159 | fn empty_sources_returns_zerorust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/tests/empty_sources_returns_zero().() { |
| 160 | let mut cache = GraphHeightCacherust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/GraphHeightCache#::defaultrust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/impl#[GraphHeightCache][Default]default().(); |
| 161 | let last_time = Instantrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/Instant#::nowrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[Instant]now().(); |
| 162 | let times: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Instantrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/Instant#> = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![]; |
| 163 | let sources: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<ChunkedDatarust-analyzer cargo timeless 0.1.0 data/chunked/ChunkedData#<f64>> = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![]; |
| 164 | |
| 165 | let result = cache.get_or_updaterust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/impl#[GraphHeightCache]get_or_update().(&last_time, 1_000, sources.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().(), ×); |
| 166 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(result, 0.0); |
| 167 | assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(cache.innerrust-analyzer cargo bottom 0.14.9 components/time_series/auto_y/GraphHeightCache#inner..is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().()); |
| 168 | } |
| 169 | } |