File tree Expand file tree Collapse file tree 4 files changed +10
-15
lines changed Expand file tree Collapse file tree 4 files changed +10
-15
lines changed Original file line number Diff line number Diff line change @@ -13,8 +13,7 @@ repository = "https://github.com/Nertsal/stecs"
13
13
[features ]
14
14
default = [" slotmap" , " query_mut" ]
15
15
query_mut = [" stecs-derive/query_mut" ]
16
- slotmap = [" dep:slotmap" ]
17
- dynamic = [" stecs-derive/dynamic" , " dep:anymap3" ]
16
+ dynamic = [" stecs-derive/dynamic" ]
18
17
19
18
[workspace ]
20
19
members = [" crates/*" ]
Original file line number Diff line number Diff line change @@ -743,15 +743,17 @@ The given `ids` must not repeat and must be valid and present id's in the storag
743
743
#[ doc = #insert_dyn_doc]
744
744
pub fn insert_dyn<__T>( & mut self , id: #generic_family_name:: Id , component: __T)
745
745
where
746
- #generic_family_name:: Storage <__T>: :: anymap3:: CloneAny
746
+ __T: Clone + ' static ,
747
+ #generic_family_name:: Id : ' static ,
747
748
{
748
749
self . r#dyn. insert( id, component)
749
750
}
750
751
751
752
#[ doc = #remove_dyn_doc]
752
753
pub fn remove_dyn<__T>( & mut self , id: #generic_family_name:: Id ) -> Option <__T>
753
754
where
754
- #generic_family_name:: Storage <__T>: :: anymap3:: CloneAny
755
+ __T: Clone + ' static ,
756
+ #generic_family_name:: Id : ' static ,
755
757
{
756
758
self . r#dyn. remove( id)
757
759
}
Original file line number Diff line number Diff line change 1
- use crate :: storage:: { Storage , StorageFamily } ;
1
+ use crate :: storage:: { sparse :: Sparse , Storage , StorageFamily } ;
2
2
3
3
use std:: marker:: PhantomData ;
4
4
@@ -15,11 +15,7 @@ pub struct DynamicStorage<F> {
15
15
id : PhantomData < F > ,
16
16
}
17
17
18
- // TODO: should really be Sparse most of the time;
19
- // maybe independent from the main storage type.
20
- // Could depend on component type via a trait,
21
- // but then we cannot match Id's freely.
22
- type InnerMap < F , T > = <F as StorageFamily >:: Storage < T > ;
18
+ type InnerMap < F , T > = Sparse < T , <F as StorageFamily >:: Id > ;
23
19
24
20
impl < F > Clone for DynamicStorage < F > {
25
21
fn clone ( & self ) -> Self {
Original file line number Diff line number Diff line change 1
- #[ cfg( feature = "slotmap" ) ]
2
1
pub mod dense;
3
- #[ cfg( feature = "slotmap" ) ]
4
2
pub mod sparse;
5
3
6
4
/// A storage of components.
7
5
pub trait Storage < T > : Default {
8
6
/// Type of the abstract family corresponding to the storages of this type.
9
7
type Family : StorageFamily ;
10
8
/// Type of the identifier used for components/entities.
11
- type Id : Copy ;
9
+ type Id : slotmap :: Key ;
12
10
13
11
/// Insert a new component to at the specified id.
14
12
fn insert ( & mut self , id : Self :: Id , value : T ) ;
@@ -44,7 +42,7 @@ pub trait Storage<T>: Default {
44
42
/// A family of storages for different component types.
45
43
pub trait StorageFamily {
46
44
/// Type of the identifier used for components/entities.
47
- type Id : Copy ;
45
+ type Id : slotmap :: Key ;
48
46
/// Type of a specific storage.
49
47
type Storage < T > : Storage < T , Family = Self , Id = Self :: Id > ;
50
48
type Generator : IdGenerator < Id = Self :: Id > ;
@@ -59,7 +57,7 @@ pub trait StorageFamily {
59
57
///
60
58
pub unsafe trait IdGenerator {
61
59
/// The identifier type being generated.
62
- type Id : Copy ;
60
+ type Id : slotmap :: Key ;
63
61
64
62
/// Returns the unique id's of all active entities in the storage in an arbitrary order.
65
63
///
You can’t perform that action at this time.
0 commit comments