Skip to main content

ferroui_livecharts/kernel/
error.rs

1//! The asymmetric extent of a coordinate's error bars.
2
3#[derive(Clone, Copy, Debug, PartialEq)]
4pub struct Error {
5    pub xi: f64,
6    pub xj: f64,
7    pub yi: f64,
8    pub yj: f64,
9    pub is_empty: bool,
10}
11
12impl Error {
13    pub const EMPTY: Self = Self {
14        xi: 0.0,
15        xj: 0.0,
16        yi: 0.0,
17        yj: 0.0,
18        is_empty: true,
19    };
20
21    pub const fn new(xi: f64, xj: f64, yi: f64, yj: f64) -> Self {
22        Self {
23            xi,
24            xj,
25            yi,
26            yj,
27            is_empty: false,
28        }
29    }
30
31    pub const fn symmetric(x: f64, y: f64) -> Self {
32        Self::new(x, x, y, y)
33    }
34}
35
36impl Default for Error {
37    fn default() -> Self {
38        Self::new(0.0, 0.0, 0.0, 0.0)
39    }
40}