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

Updated traits to use the required dyn keyword #196

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/lib/src/view/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ fn load_grass_texture<'a, 'b:'a>(
let grass_texture = yaglw::texture::Texture2D::new(&gl);
let fd = std::fs::File::open("textures/Free_Vector_Grass.png").unwrap();
let buffered_file = std::io::BufReader::new(fd);
let image = try!(image::load(buffered_file, image::ImageFormat::PNG));
let image = image::load(buffered_file, image::ImageFormat::PNG)?;
let (w, h) = image.dimensions();
let colortype = image.color();
assert!(colortype == image::ColorType::RGBA(8));
Expand Down
2 changes: 1 addition & 1 deletion common/closure_series.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub enum Return {
pub use self::Return::*;

/// The closure type used.
pub type Closure<'a> = Box<FnMut() -> Return + 'a>;
pub type Closure<'a> = Box<dyn FnMut() -> Return + 'a>;

#[allow(missing_docs)]
pub struct T<'a> {
Expand Down
4 changes: 2 additions & 2 deletions common/surroundings_loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use stopwatch;

use cube_shell::{cube_diff, cube_shell};

fn surroundings_iter(center: Point3<i32>, max_distance: i32) -> Box<Iterator<Item=Point3<i32>> + Send> {
fn surroundings_iter(center: Point3<i32>, max_distance: i32) -> Box<dyn Iterator<Item=Point3<i32>> + Send> {
Box::new((0 .. max_distance).flat_map(move |radius| cube_shell(&center, radius)))
}

Expand All @@ -30,7 +30,7 @@ pub struct T {
last_position: Option<Point3<i32>>,

max_load_distance: u32,
to_load: Option<Box<Iterator<Item=Point3<i32>> + Send>>,
to_load: Option<Box<dyn Iterator<Item=Point3<i32>> + Send>>,

to_recheck: VecDeque<Point3<i32>>,
// The distances to the switches between LODs.
Expand Down
6 changes: 3 additions & 3 deletions server/lib/src/client_recv_thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ pub fn apply_client_update<UpdateGaia>(
Point3::new(high.x.ceil() as i32, high.y.ceil() as i32, high.z.ceil() as i32)
},
),
mosaic: Box::new(tree) as Box<voxel_data::mosaic::T<voxel::Material> + Send>,
mosaic: Box::new(tree) as Box<dyn voxel_data::mosaic::T<voxel::Material> + Send>,
min_lg_size: 0,
};

Expand Down Expand Up @@ -228,10 +228,10 @@ pub fn apply_client_update<UpdateGaia>(
Point3::new(high.x.ceil() as i32, high.y.ceil() as i32, high.z.ceil() as i32)
},
),
mosaic: Box::new(sphere) as Box<voxel_data::mosaic::T<voxel::Material> + Send>,
mosaic: Box::new(sphere) as Box<dyn voxel_data::mosaic::T<voxel::Material> + Send>,
min_lg_size: 0,
};
let brush: voxel_data::brush::T<Box<voxel_data::mosaic::T<voxel::Material> + Send>> = brush;
let brush: voxel_data::brush::T<Box<dyn voxel_data::mosaic::T<voxel::Material> + Send>> = brush;
update_gaia(update_gaia::Message::Brush(brush));
});
},
Expand Down
1 change: 0 additions & 1 deletion server/lib/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ pub struct Client {
impl Client {
#[allow(missing_docs)]
pub fn send(&mut self, msg: protocol::ServerToClient) {
use bincode;
use bincode::serialize;
let msg = serialize(&msg, bincode::Infinite).unwrap();
match self.socket.write(msg.as_ref()) {
Expand Down
2 changes: 1 addition & 1 deletion server/lib/src/update_gaia.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub enum Message {
/// Load some voxels
Load(u64, Vec<voxel::bounds::T>, LoadDestination),
/// Apply a brush operation
Brush(voxel_data::brush::T<Box<voxel_data::mosaic::T<common::voxel::Material> + Send>>),
Brush(voxel_data::brush::T<Box<dyn voxel_data::mosaic::T<common::voxel::Material> + Send>>),
}

// TODO: Consider adding terrain loads to a thread pool instead of having one monolithic separate thread.
Expand Down
4 changes: 2 additions & 2 deletions server/lib/terrain/cache_mosaic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ impl std::hash::Hash for Key {
pub type Cache<T> = lru_cache::LruCache<Key, T, std::hash::BuildHasherDefault<fnv::FnvHasher>>;

pub struct T<Material> {
pub mosaic : Box<voxel::mosaic::T<Material> + Send>,
pub mosaic : Box<dyn voxel::mosaic::T<Material> + Send>,
pub density : Cache<f32>,
pub normal : Cache<cgmath::Vector3<f32>>,
pub mosaic_density : Cache<f32>,
pub mosaic_material : Cache<Option<Material>>,
}

pub fn new<Material>(mosaic: Box<voxel::mosaic::T<Material> + Send>) -> T<Material> {
pub fn new<Material>(mosaic: Box<dyn voxel::mosaic::T<Material> + Send>) -> T<Material> {
T {
mosaic : mosaic,
density : lru_cache::LruCache::with_hasher(1 << 10, Default::default()),
Expand Down