Skip to content

Commit 384b4d0

Browse files
bors[bot]torkleyy
andcommitted
Merge #515
515: Allow accessing fetched entities of a `Storage` r=Xaeroxe a=torkleyy I've added `Storage::entities` to allow making extension methods for `Storage` that return `Entity`. This method is hidden because I'm 100% certain newcomers will be confused by this otherwise. This makes it less visible, yes, but I think that's worth for avoiding this confusion. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/slide-rs/specs/515) <!-- Reviewable:end --> Co-authored-by: Thomas Schaller <torkleyy@gmail.com>
2 parents df24334 + 1a730dc commit 384b4d0

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "specs"
3-
version = "0.14.0"
3+
version = "0.14.1"
44
description = """
55
Specs is an Entity-Component System library written in Rust.
66
"""

src/storage/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,14 @@ where
202202
&self.data.inner
203203
}
204204

205+
/// Returns the `EntitesRes` resource fetched by this storage.
206+
/// **This does not have anything to do with the components inside.**
207+
/// You only want to use this when implementing additional methods
208+
/// for `Storage` via an extension trait.
209+
pub fn fetched_entities(&self) -> &EntitiesRes {
210+
&self.entities
211+
}
212+
205213
/// Tries to read the data associated with an `Entity`.
206214
pub fn get(&self, e: Entity) -> Option<&T> {
207215
if self.data.mask.contains(e.id()) && self.entities.is_alive(e) {

0 commit comments

Comments
 (0)