Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Uriopass committed Jan 16, 2024
1 parent a4de3cf commit 48fdfae
Show file tree
Hide file tree
Showing 8 changed files with 378 additions and 75 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

68 changes: 68 additions & 0 deletions common/src/iter.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
pub fn chain<T: TupleITChain>(t: T) -> T::Iter {
t.chain()
}

pub trait TupleITChain {
type Item;
type Iter: Iterator<Item = Self::Item>;

fn chain(self) -> Self::Iter;
}

impl<Item, A: Iterator<Item = Item>, B: Iterator<Item = Item>> TupleITChain for (A, B) {
type Item = Item;
type Iter = std::iter::Chain<A, B>;

fn chain(self) -> Self::Iter {
self.0.chain(self.1)
}
}

impl<Item, A: Iterator<Item = Item>, B: Iterator<Item = Item>, C: Iterator<Item = Item>>
TupleITChain for (A, B, C)
{
type Item = Item;
type Iter = std::iter::Chain<std::iter::Chain<A, B>, C>;

fn chain(self) -> Self::Iter {
self.0.chain(self.1).chain(self.2)
}
}

impl<
Item,
A: Iterator<Item = Item>,
B: Iterator<Item = Item>,
C: Iterator<Item = Item>,
D: Iterator<Item = Item>,
> TupleITChain for (A, B, C, D)
{
type Item = Item;
type Iter = std::iter::Chain<std::iter::Chain<std::iter::Chain<A, B>, C>, D>;

fn chain(self) -> Self::Iter {
self.0.chain(self.1).chain(self.2).chain(self.3)
}
}

impl<
Item,
A: Iterator<Item = Item>,
B: Iterator<Item = Item>,
C: Iterator<Item = Item>,
D: Iterator<Item = Item>,
E: Iterator<Item = Item>,
> TupleITChain for (A, B, C, D, E)
{
type Item = Item;
type Iter =
std::iter::Chain<std::iter::Chain<std::iter::Chain<std::iter::Chain<A, B>, C>, D>, E>;

fn chain(self) -> Self::Iter {
self.0
.chain(self.1)
.chain(self.2)
.chain(self.3)
.chain(self.4)
}
}
1 change: 1 addition & 0 deletions common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ mod chunkid;
pub mod error;
mod hash;
pub mod history;
pub mod iter;
pub mod logger;
pub mod macros;
pub mod rand;
Expand Down
13 changes: 7 additions & 6 deletions simulation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,22 @@ edition = "2021"
ordered-float = { workspace = true }
serde = { version = "1.0", features = ["derive"] }
log = "0.4.11"
egui-inspect = { path = "../egui-inspect"}
flat_spatial = { workspace = true, features=["serde"] }
egui-inspect = { path = "../egui-inspect"}
flat_spatial = { workspace = true, features=["serde"] }
geom = { path = "../geom" }
common = { path = "../common" }
prototypes = { path = "../prototypes" }
slotmapd = { version = "1.0", default-features = false, features = ["serde", "unstable"] }
slotmapd = { version = "1.0", default-features = false, features = ["serde", "unstable"] }
rayon = "1.6"
profiling = { version = "1.0.5", default-features = false }
inline_tweak = { version = "1.0.9", features = ["release_tweak"] }
profiling = { version = "1.0.5", default-features = false }
inline_tweak = { version = "1.0.9", features = ["release_tweak"] }
pathfinding = "4.2.1"
serde-big-array = "0.5.0"
lazy_static = "1.4.0"
arc-swap = "1.3.0"
derive_more = { workspace = true }
bitflags = "2.4.1"
bitflags = "2.4.1"
itertools = "0.12.0"

[dev-dependencies]
easybench = "1.1.0"
Expand Down
Loading

0 comments on commit 48fdfae

Please sign in to comment.