Skip to content

Commit 5f5bfba

Browse files
authored
Merge pull request #232 from lain-dono/rm-derivative
Removing derivative from dependencies
2 parents e6d6e27 + 65f1635 commit 5f5bfba

File tree

7 files changed

+85
-33
lines changed

7 files changed

+85
-33
lines changed

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ legion_codegen = { path = "codegen", version = "0.3", optional = true }
2525
smallvec = "1.4"
2626
itertools = "0.9"
2727
downcast-rs = "1.2"
28-
derivative = "2.1"
2928
paste = "1.0.0"
3029
parking_lot = "0.11"
3130
bit-set = "0.5"
@@ -58,4 +57,4 @@ harness = false
5857

5958
[[bench]]
6059
name = "insertion"
61-
harness = false
60+
harness = false

src/internals/query/view/read.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,18 @@ use crate::internals::{
1515
},
1616
subworld::ComponentAccess,
1717
};
18-
use derivative::Derivative;
1918
use std::{any::TypeId, marker::PhantomData, slice::Iter};
2019

2120
/// Reads a single entity data component type from a chunk.
22-
#[derive(Derivative, Debug, Copy, Clone)]
23-
#[derivative(Default(bound = ""))]
21+
#[derive(Debug, Copy, Clone)]
2422
pub struct Read<T>(PhantomData<*const T>);
2523

24+
impl<T> Default for Read<T> {
25+
fn default() -> Self {
26+
Self(PhantomData)
27+
}
28+
}
29+
2630
unsafe impl<T> Send for Read<T> {}
2731
unsafe impl<T: Sync> Sync for Read<T> {}
2832
unsafe impl<T> ReadOnly for Read<T> {}

src/internals/query/view/try_read.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,18 @@ use crate::internals::{
1515
},
1616
subworld::ComponentAccess,
1717
};
18-
use derivative::Derivative;
1918
use std::{any::TypeId, marker::PhantomData};
2019

2120
/// Reads a single entity data component type from a chunk.
22-
#[derive(Derivative, Debug, Copy, Clone)]
23-
#[derivative(Default(bound = ""))]
21+
#[derive(Debug, Copy, Clone)]
2422
pub struct TryRead<T>(PhantomData<*const T>);
2523

24+
impl<T> Default for TryRead<T> {
25+
fn default() -> Self {
26+
Self(PhantomData)
27+
}
28+
}
29+
2630
unsafe impl<T> Send for TryRead<T> {}
2731
unsafe impl<T: Sync> Sync for TryRead<T> {}
2832
unsafe impl<T> ReadOnly for TryRead<T> {}

src/internals/query/view/try_write.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,18 @@ use crate::internals::{
1515
},
1616
subworld::ComponentAccess,
1717
};
18-
use derivative::Derivative;
1918
use std::{any::TypeId, marker::PhantomData};
2019

2120
/// Writes a single entity data component type from a chunk.
22-
#[derive(Derivative, Debug, Copy, Clone)]
23-
#[derivative(Default(bound = ""))]
21+
#[derive(Debug, Copy, Clone)]
2422
pub struct TryWrite<T>(PhantomData<*const T>);
2523

24+
impl<T> Default for TryWrite<T> {
25+
fn default() -> Self {
26+
Self(PhantomData)
27+
}
28+
}
29+
2630
unsafe impl<T: Send> Send for TryWrite<T> {}
2731
unsafe impl<T> Sync for TryWrite<T> {}
2832

src/internals/query/view/write.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,18 @@ use crate::internals::{
1515
},
1616
subworld::ComponentAccess,
1717
};
18-
use derivative::Derivative;
1918
use std::{any::TypeId, marker::PhantomData, slice::Iter};
2019

2120
/// Writes a single mutable entity data component type from a chunk.
22-
#[derive(Derivative, Debug, Copy, Clone)]
23-
#[derivative(Default(bound = ""))]
21+
#[derive(Debug, Copy, Clone)]
2422
pub struct Write<T>(PhantomData<*const T>);
2523

24+
impl<T> Default for Write<T> {
25+
fn default() -> Self {
26+
Self(PhantomData)
27+
}
28+
}
29+
2630
unsafe impl<T: Send> Send for Write<T> {}
2731
unsafe impl<T> Sync for Write<T> {}
2832

src/internals/storage/slicevec.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
11
//! A vector of slices.
22
3-
use derivative::Derivative;
43
use std::iter::{FusedIterator, IntoIterator};
54

65
/// A vector of slices.
76
///
87
/// Each slice is stored inline so as to be efficiently iterated through linearly.
9-
#[derive(Derivative, Debug)]
10-
#[derivative(Default(bound = ""))]
8+
#[derive(Debug)]
119
pub struct SliceVec<T> {
1210
data: Vec<T>,
1311
counts: Vec<usize>,
1412
indices: Vec<usize>,
1513
}
1614

15+
impl<T> Default for SliceVec<T> {
16+
fn default() -> Self {
17+
Self {
18+
data: Vec::new(),
19+
counts: Vec::new(),
20+
indices: Vec::new(),
21+
}
22+
}
23+
}
24+
1725
impl<T> SliceVec<T> {
1826
/// Pushes a new slice onto the end of the vector.
1927
pub fn push<I: IntoIterator<Item = T>>(&mut self, items: I) {

src/internals/systems/command.rs

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@ use crate::{
1717
},
1818
world::Allocate,
1919
};
20-
use derivative::Derivative;
2120
use smallvec::SmallVec;
22-
use std::ops::Range;
2321
use std::{
22+
any::type_name,
2423
collections::VecDeque,
24+
fmt,
2525
iter::{Fuse, FusedIterator},
2626
marker::PhantomData,
27+
ops::Range,
2728
sync::Arc,
2829
};
2930

@@ -36,14 +37,21 @@ pub trait WorldWritable: Send + Sync {
3637
fn write(self: Arc<Self>, world: &mut World, cmd: &CommandBuffer);
3738
}
3839

39-
#[derive(Derivative)]
40-
#[derivative(Debug(bound = ""))]
4140
struct InsertBufferedCommand<T> {
42-
#[derivative(Debug = "ignore")]
4341
components: T,
4442
entities: Range<usize>,
4543
}
4644

45+
impl<T> fmt::Debug for InsertBufferedCommand<T> {
46+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
47+
f.write_fmt(format_args!(
48+
"InsertBufferedCommand<{}>({:?})",
49+
type_name::<T>(),
50+
self.entities
51+
))
52+
}
53+
}
54+
4755
impl<T> WorldWritable for InsertBufferedCommand<T>
4856
where
4957
T: ComponentSource + Send + Sync,
@@ -125,13 +133,16 @@ impl<'a, T, A: Iterator<Item = T> + FusedIterator, B: Iterator<Item = T>> Iterat
125133
}
126134
}
127135

128-
#[derive(Derivative)]
129-
#[derivative(Debug(bound = ""))]
130136
struct InsertCommand<T> {
131-
#[derivative(Debug = "ignore")]
132137
components: T,
133138
}
134139

140+
impl<T> fmt::Debug for InsertCommand<T> {
141+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
142+
f.write_fmt(format_args!("InsertCommand<{}>", type_name::<T>()))
143+
}
144+
}
145+
135146
impl<T> WorldWritable for InsertCommand<T>
136147
where
137148
T: IntoComponentSource + Send + Sync,
@@ -142,25 +153,35 @@ where
142153
}
143154
}
144155

145-
#[derive(Derivative)]
146-
#[derivative(Debug(bound = ""))]
147156
struct DeleteEntityCommand(Entity);
148157

158+
impl fmt::Debug for DeleteEntityCommand {
159+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
160+
f.write_fmt(format_args!("DeleteEntityCommand({:?})", self.0))
161+
}
162+
}
163+
149164
impl WorldWritable for DeleteEntityCommand {
150165
fn write(self: Arc<Self>, world: &mut World, _: &CommandBuffer) {
151166
world.remove(self.0);
152167
}
153168
}
154169

155-
#[derive(Derivative)]
156-
#[derivative(Debug(bound = ""))]
157170
struct AddComponentCommand<C> {
158-
#[derivative(Debug = "ignore")]
159171
entity: Entity,
160-
#[derivative(Debug = "ignore")]
161172
component: C,
162173
}
163174

175+
impl<T> fmt::Debug for AddComponentCommand<T> {
176+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
177+
f.write_fmt(format_args!(
178+
"AddComponentCommand<{}>({:?})",
179+
type_name::<T>(),
180+
self.entity
181+
))
182+
}
183+
}
184+
164185
impl<C> WorldWritable for AddComponentCommand<C>
165186
where
166187
C: Component,
@@ -174,13 +195,21 @@ where
174195
}
175196
}
176197

177-
#[derive(Derivative)]
178-
#[derivative(Debug(bound = ""))]
179198
struct RemoveComponentCommand<C> {
180199
entity: Entity,
181200
_marker: PhantomData<C>,
182201
}
183202

203+
impl<T> fmt::Debug for RemoveComponentCommand<T> {
204+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
205+
f.write_fmt(format_args!(
206+
"RemoveComponentCommand<{}>({:?})",
207+
type_name::<T>(),
208+
self.entity
209+
))
210+
}
211+
}
212+
184213
impl<C> WorldWritable for RemoveComponentCommand<C>
185214
where
186215
C: Component,

0 commit comments

Comments
 (0)