From 759bb3f90eba9cfff0ce609e8387da32dfda593b Mon Sep 17 00:00:00 2001 From: lucanLepus Date: Sun, 9 Jun 2019 13:48:11 +0200 Subject: [PATCH] fix bare trait object warnings on rust-nightly --- examples/blit.rs | 4 ++-- examples/samples.rs | 8 ++++---- src/bsp.rs | 2 +- src/console.rs | 4 ++-- src/pathfinding.rs | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/blit.rs b/examples/blit.rs index 3a939ebd1..4d9ffd9c1 100644 --- a/examples/blit.rs +++ b/examples/blit.rs @@ -13,8 +13,8 @@ fn main() { let mut direct: OffscreenConsole = OffscreenConsole::new(20, 20); let mut boxed_direct: Box = Box::new(OffscreenConsole::new(20, 20)); - let mut trait_object: &Console = &OffscreenConsole::new(20, 20); - let mut boxed_trait: Box = Box::new(OffscreenConsole::new(20, 20)); + let mut trait_object: &dyn Console = &OffscreenConsole::new(20, 20); + let mut boxed_trait: Box = Box::new(OffscreenConsole::new(20, 20)); root.set_default_background(colors::DARKEST_GREEN); diff --git a/examples/samples.rs b/examples/samples.rs index 41db2cd3c..03e069af4 100644 --- a/examples/samples.rs +++ b/examples/samples.rs @@ -92,7 +92,7 @@ impl ColorsSample { } - fn set_colors(&self, console: &mut Console) { + fn set_colors(&self, console: &mut dyn Console) { enum Dir { TopLeft = 0, TopRight, @@ -121,7 +121,7 @@ impl ColorsSample { } } - fn print_random_chars(&mut self, console: &mut Console) -> colors::Color { + fn print_random_chars(&mut self, console: &mut dyn Console) -> colors::Color { // ==== print the text with a random color ==== // get the background color at the text position let mut text_color = console.get_char_background(SAMPLE_SCREEN_WIDTH/2, 5); @@ -1519,11 +1519,11 @@ impl Render for NameSample { struct MenuItem<'a> { name: String, - render: &'a mut Render + render: &'a mut dyn Render } impl<'a> MenuItem<'a> { - fn new(name: &str, render: &'a mut Render) -> Self { + fn new(name: &str, render: &'a mut dyn Render) -> Self { MenuItem { name: name.to_owned(), render: render } } } diff --git a/src/bsp.rs b/src/bsp.rs index 1b9ee748f..0b338cb7d 100644 --- a/src/bsp.rs +++ b/src/bsp.rs @@ -220,7 +220,7 @@ impl<'a> Bsp<'a> { pub fn traverse(&self, order: TraverseOrder, mut callback: F) -> bool where F: FnMut(&mut Bsp) -> bool { - let cb: &mut FnMut(&mut Bsp) -> bool = &mut callback; + let cb: &mut dyn FnMut(&mut Bsp) -> bool = &mut callback; let retval = unsafe { let bsp = mem::transmute(self.bsp as *const ffi::TCOD_bsp_t); match order { diff --git a/src/console.rs b/src/console.rs index 62f687255..7e6626595 100644 --- a/src/console.rs +++ b/src/console.rs @@ -461,9 +461,9 @@ impl Root { pub struct RootInitializer<'a> { width: i32, height: i32, - title: Box + 'a>, + title: Box + 'a>, is_fullscreen: bool, - font_path: Box + 'a>, + font_path: Box + 'a>, font_layout: FontLayout, font_type: FontType, font_dimensions: (i32, i32), diff --git a/src/pathfinding.rs b/src/pathfinding.rs index 99c169853..9a679d192 100644 --- a/src/pathfinding.rs +++ b/src/pathfinding.rs @@ -4,7 +4,7 @@ use map::Map; enum PathInnerData<'a> { Map(Map), - Callback(Box f32+'a>), + Callback(Box f32+'a>), } pub struct AStar<'a>{