bitrot: replace bare traits object syntax with dyn traits

This commit is contained in:
2021-02-04 06:24:35 -08:00
parent dea54e4883
commit 9dd48d359c
6 changed files with 13 additions and 13 deletions

View File

@@ -35,13 +35,13 @@ impl world::Map for Field {
}
impl world::HasMap for Arena {
fn map(&self) -> &world::Map {
fn map(&self) -> &dyn world::Map {
&self.map
}
}
impl world::HasMap for Shrine {
fn map(&self) -> &world::Map {
fn map(&self) -> &dyn world::Map {
&self.map
}
}

View File

@@ -11,7 +11,7 @@ use itertools::Itertools;
use memmap::{Mmap, Protection};
fn mmap_to_rows<'a, M: world::HasMap>(mmap: &memmap::Mmap) -> &'a world::HasMap
fn mmap_to_rows<'a, M: world::HasMap>(mmap: &memmap::Mmap) -> &'a dyn world::HasMap
where M: Copy + 'a
{
assert_eq!(std::mem::size_of::<M>(), mmap.len());

View File

@@ -26,7 +26,7 @@ pub struct Town {
}
impl HasMap for Town {
fn map(&self) -> &Map {
fn map(&self) -> &dyn Map {
&self.map
}
}

View File

@@ -68,7 +68,7 @@ impl ViewRoot<gfx_device_gl::Device, ColorFormat, DepthFormat> {
pub fn draw(&self,
window: &mut PistonWindow,
vr: &mut Option<vr::VR>,
scene: &::scene::Scene<gfx_device_gl::Device, gfx_device_gl::Factory>)
scene: &dyn (::scene::Scene<gfx_device_gl::Device, gfx_device_gl::Factory>))
-> Result<(), vr::Error>
{
if let &mut Some(ref mut vr) = vr {

View File

@@ -35,9 +35,9 @@ pub use self::vr::button_id;
#[derive(Debug)]
pub enum Error {
Init(Box<Debug>),
Poses(Box<Debug>),
Submit(Box<Debug>)
Init(Box<dyn Debug>),
Poses(Box<dyn Debug>),
Submit(Box<dyn Debug>)
}
impl From<vr::InitError> for Error {

View File

@@ -1,16 +1,16 @@
use tile::Tile;
use transpose::TransposableIterator;
pub type RowIterator<'a> = Box<Iterator<Item = &'a Tile> + 'a>;
pub type BoxedMapIterator<'a> = Box<Iterator<Item = RowIterator<'a>> + 'a>;
pub type ExactBoxedMapIterator<'a> = Box<ExactSizeIterator<Item = RowIterator<'a>> + 'a>;
pub type RowIterator<'a> = Box<dyn Iterator<Item = &'a Tile> + 'a>;
pub type BoxedMapIterator<'a> = Box<dyn Iterator<Item = RowIterator<'a>> + 'a>;
pub type ExactBoxedMapIterator<'a> = Box<dyn ExactSizeIterator<Item = RowIterator<'a>> + 'a>;
pub trait Map {
fn rows<'a>(&'a self) -> BoxedMapIterator;
}
pub trait HasMap {
fn map(&self) -> &Map;
fn map(&self) -> &dyn Map;
}
const CHUNKDIM: usize = 32;
@@ -64,7 +64,7 @@ impl Map for World {
}
impl HasMap for World {
fn map(&self) -> &Map {
fn map(&self) -> &dyn Map {
self
}
}