Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relax 'static bound on plugins #87

Merged
merged 1 commit into from
Dec 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions walkers/src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ pub trait Plugin {
/// ));
/// }
/// ```
pub struct Map<'a, 'b> {
pub struct Map<'a, 'b, 'c> {
tiles: Option<&'b mut Tiles>,
memory: &'a mut MapMemory,
my_position: Position,
plugins: Vec<Box<dyn Plugin>>,
plugins: Vec<Box<dyn Plugin + 'c>>,
}

impl<'a, 'b> Map<'a, 'b> {
impl<'a, 'b, 'c> Map<'a, 'b, 'c> {
pub fn new(
tiles: Option<&'b mut Tiles>,
memory: &'a mut MapMemory,
Expand All @@ -54,7 +54,7 @@ impl<'a, 'b> Map<'a, 'b> {
}

/// Add plugin to the drawing pipeline. Plugins allow drawing custom shapes on the map.
pub fn with_plugin(mut self, plugin: impl Plugin + 'static) -> Self {
pub fn with_plugin(mut self, plugin: impl Plugin + 'c) -> Self {
self.plugins.push(Box::new(plugin));
self
}
Expand Down Expand Up @@ -89,7 +89,7 @@ impl Projector {
}
}

impl Map<'_, '_> {
impl Map<'_, '_, '_> {
/// Handle zoom and drag inputs, and recalculate everything accordingly.
fn zoom_and_drag(&mut self, ui: &mut Ui, response: &Response) {
let zoom_delta = ui.input(|input| input.zoom_delta());
Expand Down Expand Up @@ -139,7 +139,7 @@ impl Map<'_, '_> {
}
}

impl Widget for Map<'_, '_> {
impl Widget for Map<'_, '_, '_> {
fn ui(mut self, ui: &mut Ui) -> Response {
let (rect, response) = ui.allocate_exact_size(ui.available_size(), Sense::drag());

Expand Down
Loading