clippy fixes
This commit is contained in:
parent
ab77099781
commit
39dd6d7644
5 changed files with 19 additions and 56 deletions
|
@ -3,7 +3,7 @@ use std::hash::Hash;
|
||||||
use crate::*;
|
use crate::*;
|
||||||
use epaint::{Shape, TextStyle};
|
use epaint::{Shape, TextStyle};
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug, Default)]
|
||||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "serde", serde(default))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
pub(crate) struct State {
|
pub(crate) struct State {
|
||||||
|
@ -13,15 +13,6 @@ pub(crate) struct State {
|
||||||
open_height: Option<f32>,
|
open_height: Option<f32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for State {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self {
|
|
||||||
open: false,
|
|
||||||
open_height: None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl State {
|
impl State {
|
||||||
pub fn load(ctx: &Context, id: Id) -> Option<Self> {
|
pub fn load(ctx: &Context, id: Id) -> Option<Self> {
|
||||||
ctx.memory().data.get_persisted(id)
|
ctx.memory().data.get_persisted(id)
|
||||||
|
|
|
@ -311,19 +311,19 @@ use crate::Id;
|
||||||
/// map.insert_temp(a, 42);
|
/// map.insert_temp(a, 42);
|
||||||
///
|
///
|
||||||
/// // `b` associated with an f64 and a `&'static str`
|
/// // `b` associated with an f64 and a `&'static str`
|
||||||
/// map.insert_persisted(b, 6.28);
|
/// map.insert_persisted(b, 13.37);
|
||||||
/// map.insert_temp(b, "Hello World".to_string());
|
/// map.insert_temp(b, "Hello World".to_string());
|
||||||
///
|
///
|
||||||
/// // we can retrieve all four values:
|
/// // we can retrieve all four values:
|
||||||
/// assert_eq!(map.get_temp::<f64>(a), Some(3.14));
|
/// assert_eq!(map.get_temp::<f64>(a), Some(3.14));
|
||||||
/// assert_eq!(map.get_temp::<i32>(a), Some(42));
|
/// assert_eq!(map.get_temp::<i32>(a), Some(42));
|
||||||
/// assert_eq!(map.get_temp::<f64>(b), Some(6.28));
|
/// assert_eq!(map.get_temp::<f64>(b), Some(13.37));
|
||||||
/// assert_eq!(map.get_temp::<String>(b), Some("Hello World".to_string()));
|
/// assert_eq!(map.get_temp::<String>(b), Some("Hello World".to_string()));
|
||||||
///
|
///
|
||||||
/// // we can retrieve them like so also:
|
/// // we can retrieve them like so also:
|
||||||
/// assert_eq!(map.get_persisted::<f64>(a), Some(3.14));
|
/// assert_eq!(map.get_persisted::<f64>(a), Some(3.14));
|
||||||
/// assert_eq!(map.get_persisted::<i32>(a), Some(42));
|
/// assert_eq!(map.get_persisted::<i32>(a), Some(42));
|
||||||
/// assert_eq!(map.get_persisted::<f64>(b), Some(6.28));
|
/// assert_eq!(map.get_persisted::<f64>(b), Some(13.37));
|
||||||
/// assert_eq!(map.get_temp::<String>(b), Some("Hello World".to_string()));
|
/// assert_eq!(map.get_temp::<String>(b), Some("Hello World".to_string()));
|
||||||
/// ```
|
/// ```
|
||||||
#[derive(Clone, Debug, Default)]
|
#[derive(Clone, Debug, Default)]
|
||||||
|
@ -544,11 +544,11 @@ fn test_two_id_two_type() {
|
||||||
let b = Id::new("b");
|
let b = Id::new("b");
|
||||||
|
|
||||||
let mut map: IdTypeMap = Default::default();
|
let mut map: IdTypeMap = Default::default();
|
||||||
map.insert_persisted(a, 6.28);
|
map.insert_persisted(a, 13.37);
|
||||||
map.insert_temp(b, 42);
|
map.insert_temp(b, 42);
|
||||||
assert_eq!(map.get_persisted::<f64>(a), Some(6.28));
|
assert_eq!(map.get_persisted::<f64>(a), Some(13.37));
|
||||||
assert_eq!(map.get_persisted::<i32>(b), Some(42));
|
assert_eq!(map.get_persisted::<i32>(b), Some(42));
|
||||||
assert_eq!(map.get_temp::<f64>(a), Some(6.28));
|
assert_eq!(map.get_temp::<f64>(a), Some(13.37));
|
||||||
assert_eq!(map.get_temp::<i32>(b), Some(42));
|
assert_eq!(map.get_temp::<i32>(b), Some(42));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -565,19 +565,19 @@ fn test_two_id_x_two_types() {
|
||||||
map.insert_temp(a, 42);
|
map.insert_temp(a, 42);
|
||||||
|
|
||||||
// `b` associated with an f64 and a `&'static str`
|
// `b` associated with an f64 and a `&'static str`
|
||||||
map.insert_persisted(b, 6.28);
|
map.insert_persisted(b, 13.37);
|
||||||
map.insert_temp(b, "Hello World".to_string());
|
map.insert_temp(b, "Hello World".to_string());
|
||||||
|
|
||||||
// we can retrieve all four values:
|
// we can retrieve all four values:
|
||||||
assert_eq!(map.get_temp::<f64>(a), Some(3.14));
|
assert_eq!(map.get_temp::<f64>(a), Some(3.14));
|
||||||
assert_eq!(map.get_temp::<i32>(a), Some(42));
|
assert_eq!(map.get_temp::<i32>(a), Some(42));
|
||||||
assert_eq!(map.get_temp::<f64>(b), Some(6.28));
|
assert_eq!(map.get_temp::<f64>(b), Some(13.37));
|
||||||
assert_eq!(map.get_temp::<String>(b), Some("Hello World".to_string()));
|
assert_eq!(map.get_temp::<String>(b), Some("Hello World".to_string()));
|
||||||
|
|
||||||
// we can retrieve them like so also:
|
// we can retrieve them like so also:
|
||||||
assert_eq!(map.get_persisted::<f64>(a), Some(3.14));
|
assert_eq!(map.get_persisted::<f64>(a), Some(3.14));
|
||||||
assert_eq!(map.get_persisted::<i32>(a), Some(42));
|
assert_eq!(map.get_persisted::<i32>(a), Some(42));
|
||||||
assert_eq!(map.get_persisted::<f64>(b), Some(6.28));
|
assert_eq!(map.get_persisted::<f64>(b), Some(13.37));
|
||||||
assert_eq!(map.get_temp::<String>(b), Some("Hello World".to_string()));
|
assert_eq!(map.get_temp::<String>(b), Some("Hello World".to_string()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -586,11 +586,11 @@ fn test_one_id_two_types() {
|
||||||
let id = Id::new("a");
|
let id = Id::new("a");
|
||||||
|
|
||||||
let mut map: IdTypeMap = Default::default();
|
let mut map: IdTypeMap = Default::default();
|
||||||
map.insert_persisted(id, 6.28);
|
map.insert_persisted(id, 13.37);
|
||||||
map.insert_temp(id, 42);
|
map.insert_temp(id, 42);
|
||||||
|
|
||||||
assert_eq!(map.get_temp::<f64>(id), Some(6.28));
|
assert_eq!(map.get_temp::<f64>(id), Some(13.37));
|
||||||
assert_eq!(map.get_persisted::<f64>(id), Some(6.28));
|
assert_eq!(map.get_persisted::<f64>(id), Some(13.37));
|
||||||
assert_eq!(map.get_temp::<i32>(id), Some(42));
|
assert_eq!(map.get_temp::<i32>(id), Some(42));
|
||||||
|
|
||||||
// ------------
|
// ------------
|
||||||
|
@ -601,8 +601,8 @@ fn test_one_id_two_types() {
|
||||||
assert_eq!(map.get_temp::<i32>(id), None);
|
assert_eq!(map.get_temp::<i32>(id), None);
|
||||||
|
|
||||||
// Other type is still there, even though it is the same if:
|
// Other type is still there, even though it is the same if:
|
||||||
assert_eq!(map.get_temp::<f64>(id), Some(6.28));
|
assert_eq!(map.get_temp::<f64>(id), Some(13.37));
|
||||||
assert_eq!(map.get_persisted::<f64>(id), Some(6.28));
|
assert_eq!(map.get_persisted::<f64>(id), Some(13.37));
|
||||||
|
|
||||||
// But we can still remove the last:
|
// But we can still remove the last:
|
||||||
map.remove::<f64>(id);
|
map.remove::<f64>(id);
|
||||||
|
|
|
@ -139,20 +139,12 @@ impl Default for Orientation {
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
pub struct Values {
|
pub struct Values {
|
||||||
pub(super) values: Vec<Value>,
|
pub(super) values: Vec<Value>,
|
||||||
generator: Option<ExplicitGenerator>,
|
generator: Option<ExplicitGenerator>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Values {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self {
|
|
||||||
values: Vec::new(),
|
|
||||||
generator: None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Values {
|
impl Values {
|
||||||
pub fn from_values(values: Vec<Value>) -> Self {
|
pub fn from_values(values: Vec<Value>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
|
|
@ -237,19 +237,11 @@ impl Widget for &mut MarkerDemo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq)]
|
#[derive(Default, PartialEq)]
|
||||||
struct LegendDemo {
|
struct LegendDemo {
|
||||||
config: Legend,
|
config: Legend,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for LegendDemo {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self {
|
|
||||||
config: Legend::default(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl LegendDemo {
|
impl LegendDemo {
|
||||||
fn line_with_slope(slope: f64) -> Line {
|
fn line_with_slope(slope: f64) -> Line {
|
||||||
Line::new(Values::from_explicit_callback(move |x| slope * x, .., 100))
|
Line::new(Values::from_explicit_callback(move |x| slope * x, .., 100))
|
||||||
|
@ -381,15 +373,9 @@ impl Widget for &mut ItemsDemo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq)]
|
#[derive(Default, PartialEq)]
|
||||||
struct InteractionDemo {}
|
struct InteractionDemo {}
|
||||||
|
|
||||||
impl Default for InteractionDemo {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Widget for &mut InteractionDemo {
|
impl Widget for &mut InteractionDemo {
|
||||||
fn ui(self, ui: &mut Ui) -> Response {
|
fn ui(self, ui: &mut Ui) -> Response {
|
||||||
let plot = Plot::new("interaction_demo").height(300.0);
|
let plot = Plot::new("interaction_demo").height(300.0);
|
||||||
|
|
|
@ -253,17 +253,11 @@ impl super::View for ScrollTo {
|
||||||
|
|
||||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||||
#[cfg_attr(feature = "serde", serde(default))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
#[derive(PartialEq)]
|
#[derive(Default, PartialEq)]
|
||||||
struct ScrollStickTo {
|
struct ScrollStickTo {
|
||||||
n_items: usize,
|
n_items: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for ScrollStickTo {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self { n_items: 0 }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl super::View for ScrollStickTo {
|
impl super::View for ScrollStickTo {
|
||||||
fn ui(&mut self, ui: &mut Ui) {
|
fn ui(&mut self, ui: &mut Ui) {
|
||||||
ui.label("Rows enter from the bottom, we want the scroll handle to start and stay at bottom unless moved");
|
ui.label("Rows enter from the bottom, we want the scroll handle to start and stay at bottom unless moved");
|
||||||
|
|
Loading…
Reference in a new issue