Skip to content

Commit

Permalink
derive default instead of impl by hand
Browse files Browse the repository at this point in the history
  • Loading branch information
podusowski committed Aug 4, 2023
1 parent 36715e5 commit d1dd589
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit d1dd589

Please sign in to comment.