From 65f1635ab26db3f537d0dbd75a57f28191fe5f30 Mon Sep 17 00:00:00 2001 From: Lain-dono Date: Sat, 30 Jan 2021 22:59:15 +0300 Subject: [PATCH] removing derivative from dependencies --- Cargo.toml | 3 +- src/internals/query/view/read.rs | 10 +++-- src/internals/query/view/try_read.rs | 10 +++-- src/internals/query/view/try_write.rs | 10 +++-- src/internals/query/view/write.rs | 10 +++-- src/internals/storage/slicevec.rs | 14 ++++-- src/internals/systems/command.rs | 61 ++++++++++++++++++++------- 7 files changed, 85 insertions(+), 33 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 53c5dd00..14d065b7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,6 @@ legion_codegen = { path = "codegen", version = "0.3", optional = true } smallvec = "1.4" itertools = "0.9" downcast-rs = "1.2" -derivative = "2.1" paste = "1.0.0" parking_lot = "0.11" bit-set = "0.5" @@ -58,4 +57,4 @@ harness = false [[bench]] name = "insertion" -harness = false \ No newline at end of file +harness = false diff --git a/src/internals/query/view/read.rs b/src/internals/query/view/read.rs index 9e8345e8..227188a3 100644 --- a/src/internals/query/view/read.rs +++ b/src/internals/query/view/read.rs @@ -15,14 +15,18 @@ use crate::internals::{ }, subworld::ComponentAccess, }; -use derivative::Derivative; use std::{any::TypeId, marker::PhantomData, slice::Iter}; /// Reads a single entity data component type from a chunk. -#[derive(Derivative, Debug, Copy, Clone)] -#[derivative(Default(bound = ""))] +#[derive(Debug, Copy, Clone)] pub struct Read(PhantomData<*const T>); +impl Default for Read { + fn default() -> Self { + Self(PhantomData) + } +} + unsafe impl Send for Read {} unsafe impl Sync for Read {} unsafe impl ReadOnly for Read {} diff --git a/src/internals/query/view/try_read.rs b/src/internals/query/view/try_read.rs index d4bd2fe5..cefbc4c9 100644 --- a/src/internals/query/view/try_read.rs +++ b/src/internals/query/view/try_read.rs @@ -15,14 +15,18 @@ use crate::internals::{ }, subworld::ComponentAccess, }; -use derivative::Derivative; use std::{any::TypeId, marker::PhantomData}; /// Reads a single entity data component type from a chunk. -#[derive(Derivative, Debug, Copy, Clone)] -#[derivative(Default(bound = ""))] +#[derive(Debug, Copy, Clone)] pub struct TryRead(PhantomData<*const T>); +impl Default for TryRead { + fn default() -> Self { + Self(PhantomData) + } +} + unsafe impl Send for TryRead {} unsafe impl Sync for TryRead {} unsafe impl ReadOnly for TryRead {} diff --git a/src/internals/query/view/try_write.rs b/src/internals/query/view/try_write.rs index 0881684d..9b850f4b 100644 --- a/src/internals/query/view/try_write.rs +++ b/src/internals/query/view/try_write.rs @@ -15,14 +15,18 @@ use crate::internals::{ }, subworld::ComponentAccess, }; -use derivative::Derivative; use std::{any::TypeId, marker::PhantomData}; /// Writes a single entity data component type from a chunk. -#[derive(Derivative, Debug, Copy, Clone)] -#[derivative(Default(bound = ""))] +#[derive(Debug, Copy, Clone)] pub struct TryWrite(PhantomData<*const T>); +impl Default for TryWrite { + fn default() -> Self { + Self(PhantomData) + } +} + unsafe impl Send for TryWrite {} unsafe impl Sync for TryWrite {} diff --git a/src/internals/query/view/write.rs b/src/internals/query/view/write.rs index b97dcdc4..016a5f3b 100644 --- a/src/internals/query/view/write.rs +++ b/src/internals/query/view/write.rs @@ -15,14 +15,18 @@ use crate::internals::{ }, subworld::ComponentAccess, }; -use derivative::Derivative; use std::{any::TypeId, marker::PhantomData, slice::Iter}; /// Writes a single mutable entity data component type from a chunk. -#[derive(Derivative, Debug, Copy, Clone)] -#[derivative(Default(bound = ""))] +#[derive(Debug, Copy, Clone)] pub struct Write(PhantomData<*const T>); +impl Default for Write { + fn default() -> Self { + Self(PhantomData) + } +} + unsafe impl Send for Write {} unsafe impl Sync for Write {} diff --git a/src/internals/storage/slicevec.rs b/src/internals/storage/slicevec.rs index 63b4bbaa..ea99bb79 100644 --- a/src/internals/storage/slicevec.rs +++ b/src/internals/storage/slicevec.rs @@ -1,19 +1,27 @@ //! A vector of slices. -use derivative::Derivative; use std::iter::{FusedIterator, IntoIterator}; /// A vector of slices. /// /// Each slice is stored inline so as to be efficiently iterated through linearly. -#[derive(Derivative, Debug)] -#[derivative(Default(bound = ""))] +#[derive(Debug)] pub struct SliceVec { data: Vec, counts: Vec, indices: Vec, } +impl Default for SliceVec { + fn default() -> Self { + Self { + data: Vec::new(), + counts: Vec::new(), + indices: Vec::new(), + } + } +} + impl SliceVec { /// Pushes a new slice onto the end of the vector. pub fn push>(&mut self, items: I) { diff --git a/src/internals/systems/command.rs b/src/internals/systems/command.rs index 5c2a2d88..63d8e9b1 100644 --- a/src/internals/systems/command.rs +++ b/src/internals/systems/command.rs @@ -17,13 +17,14 @@ use crate::{ }, world::Allocate, }; -use derivative::Derivative; use smallvec::SmallVec; -use std::ops::Range; use std::{ + any::type_name, collections::VecDeque, + fmt, iter::{Fuse, FusedIterator}, marker::PhantomData, + ops::Range, sync::Arc, }; @@ -36,14 +37,21 @@ pub trait WorldWritable: Send + Sync { fn write(self: Arc, world: &mut World, cmd: &CommandBuffer); } -#[derive(Derivative)] -#[derivative(Debug(bound = ""))] struct InsertBufferedCommand { - #[derivative(Debug = "ignore")] components: T, entities: Range, } +impl fmt::Debug for InsertBufferedCommand { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_fmt(format_args!( + "InsertBufferedCommand<{}>({:?})", + type_name::(), + self.entities + )) + } +} + impl WorldWritable for InsertBufferedCommand where T: ComponentSource + Send + Sync, @@ -125,13 +133,16 @@ impl<'a, T, A: Iterator + FusedIterator, B: Iterator> Iterat } } -#[derive(Derivative)] -#[derivative(Debug(bound = ""))] struct InsertCommand { - #[derivative(Debug = "ignore")] components: T, } +impl fmt::Debug for InsertCommand { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_fmt(format_args!("InsertCommand<{}>", type_name::())) + } +} + impl WorldWritable for InsertCommand where T: IntoComponentSource + Send + Sync, @@ -142,25 +153,35 @@ where } } -#[derive(Derivative)] -#[derivative(Debug(bound = ""))] struct DeleteEntityCommand(Entity); +impl fmt::Debug for DeleteEntityCommand { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_fmt(format_args!("DeleteEntityCommand({:?})", self.0)) + } +} + impl WorldWritable for DeleteEntityCommand { fn write(self: Arc, world: &mut World, _: &CommandBuffer) { world.remove(self.0); } } -#[derive(Derivative)] -#[derivative(Debug(bound = ""))] struct AddComponentCommand { - #[derivative(Debug = "ignore")] entity: Entity, - #[derivative(Debug = "ignore")] component: C, } +impl fmt::Debug for AddComponentCommand { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_fmt(format_args!( + "AddComponentCommand<{}>({:?})", + type_name::(), + self.entity + )) + } +} + impl WorldWritable for AddComponentCommand where C: Component, @@ -174,13 +195,21 @@ where } } -#[derive(Derivative)] -#[derivative(Debug(bound = ""))] struct RemoveComponentCommand { entity: Entity, _marker: PhantomData, } +impl fmt::Debug for RemoveComponentCommand { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.write_fmt(format_args!( + "RemoveComponentCommand<{}>({:?})", + type_name::(), + self.entity + )) + } +} + impl WorldWritable for RemoveComponentCommand where C: Component,