From d1dd5896e2237ecef23d149f42bae21f7b36e51a Mon Sep 17 00:00:00 2001 From: Piotr Podusowski Date: Fri, 4 Aug 2023 19:35:51 +0200 Subject: [PATCH] derive default instead of impl by hand --- src/map.rs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/map.rs b/src/map.rs index 8effdada..962d380a 100644 --- a/src/map.rs +++ b/src/map.rs @@ -90,9 +90,10 @@ impl Widget for Map<'_, '_> { /// is meant to be fed by a GPS sensor or other geo-localization method. If user drags the map, /// it becomes "detached" and stays this way until [`MapMemory::center_mode`] is changed back to /// [`Center::MyPosition`]. -#[derive(Clone, PartialEq)] +#[derive(Clone, PartialEq, Default)] pub enum Center { /// Center at `my_position` argument of the [`Map::new()`] function. + #[default] MyPosition, /// Center at the exact position. @@ -120,20 +121,12 @@ impl Center { } /// State of the map widget which must persist between frames. +#[derive(Default)] pub struct MapMemory { pub center_mode: Center, pub zoom: Zoom, } -impl Default for MapMemory { - fn default() -> Self { - Self { - center_mode: Center::MyPosition, - zoom: Default::default(), - } - } -} - fn draw_tiles( painter: &Painter, tile_id: TileId,