Skip to content

Commit 9920e93

Browse files
author
Daniel Griffen
committed
Commiting a bugged version for error reporting to rust
1 parent d64ef1e commit 9920e93

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

src/main.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(globs)]
1+
#![feature(globs, associated_types)]
22

33
extern crate graphics;
44
extern crate sdl2_window;
@@ -18,17 +18,13 @@ use event::{
1818
WindowSettings
1919
};
2020

21-
use event::window::Size;
22-
23-
use current::{Set, Get};
24-
21+
use current::Set;
2522
use sdl2_window::Sdl2Window;
2623
use opengl_graphics::Gl;
27-
2824
use engine::ConwayEngine;
2925
use world::World;
30-
3126
use std::cell::RefCell;
27+
3228
pub mod cell;
3329
pub mod world;
3430
pub mod engine;

src/world.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@ pub struct HashWorld {
88
pub cells: HashMap<(int, int), State>
99
}
1010

11+
/*struct HashWorldIter {
12+
iter: hash_map::Entries<(int, int), State + 'static>
13+
}*/
14+
1115
pub trait World {
16+
type WorldIter: Iterator<((int, int), State)>;
17+
1218
fn get_cell(&self, x: int, y: int) -> State;
1319

1420
fn set_cell(&mut self, x: int, y: int);
@@ -34,16 +40,30 @@ pub trait World {
3440
///This will stay in this format for the forseeable future.
3541
///Returning a generic iterator adds too much overhead to the
3642
///iter() function
37-
fn iter(&self) -> hash_map::Entries<(int, int), State>;
43+
fn iter(&self) -> World::WorldIter;
44+
}
45+
46+
47+
/*impl HashWorldIter {
48+
fn new(iter: hash_map::Entries<(int, int), State>) -> HashWorldIter {
49+
HashWorldIter { iter: iter }
50+
}
3851
}
3952
53+
impl Iterator<((int, int), State)> for HashWorldIter {
54+
fn next(&mut self) -> ((int, int), State) {
55+
self.iter.next()
56+
}
57+
}*/
58+
4059
impl HashWorld {
4160
pub fn new() -> HashWorld {
4261
HashWorld { cells: HashMap::new() }
4362
}
4463
}
4564

4665
impl World for HashWorld {
66+
type WorldIter = hash_map::Entries<(int, int), State>;
4767

4868
fn get_cell(&self, x: int, y: int) -> State {
4969
match self.cells.get(&(x, y)) {

0 commit comments

Comments
 (0)