Skip to content

Commit 0a86bab

Browse files
authored
Release commits (#79)
* chore: update to edition 2024, prepare release version * chore: update docs for release * chore: Release * chore: cargo fmt
1 parent 6df768a commit 0a86bab

File tree

19 files changed

+375
-305
lines changed

19 files changed

+375
-305
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## Version 0.16 (Bevy 0.16)
4+
5+
* Added support for Bevy 0.16.
6+
37
## Version 0.7 (Bevy 0.15)
48

59
* Added support for Bevy 0.15.

Cargo.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
[workspace]
2-
resolver = "2"
2+
resolver = "3"
33
members = [
44
"bevy-trait-query",
55
"bevy-trait-query-impl"
66
]
77

8+
[workspace.package]
9+
edition = "2024"
10+
811
[workspace.dependencies]
912
tracing = "0.1"
1013
bevy_ecs = "0.16.0"
1114
bevy_app = "0.16.0"
1215

1316
# proc macro
14-
bevy-trait-query-impl = { version = "0.7.0", path = "./bevy-trait-query-impl" }
17+
bevy-trait-query-impl = { version = "0.16.0", path = "./bevy-trait-query-impl" }
1518
proc-macro2 = "1"
1619
syn = { version = "2", features = ["full"] }
1720
quote = "1"

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Before using this crate, you should be familiar with bevy: https://bevyengine.or
1313
| Bevy Version | [Crate Version](CHANGELOG.md) |
1414
|--------------|---------------|
1515
| Preview | Main branch |
16+
| 0.16 | 0.16 |
1617
| 0.15 | 0.7 |
1718
| 0.14 | 0.6 |
1819
| 0.13 | 0.5 |
@@ -22,6 +23,8 @@ Before using this crate, you should be familiar with bevy: https://bevyengine.or
2223
| 0.9 | 0.1 |
2324
| 0.8 | 0.0.3 |
2425

26+
Since version 0.16, we're following bevy's versions. Make sure the crate versions match!
27+
2528
## Note on reliability
2629

2730
While this crate has seen some use in the world with no issues yet,

bevy-trait-query-impl/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "bevy-trait-query-impl"
3-
version = "0.7.0"
4-
edition = "2021"
3+
version = "0.16.0"
4+
edition.workspace = true
55

66
description = "Procedural macro for `bevy-trait-query`"
77
repository = "https://github.com/JoJoJet/bevy-trait-query/"

bevy-trait-query-impl/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use proc_macro::TokenStream;
22
use proc_macro2::TokenStream as TokenStream2;
33
use quote::{format_ident, quote};
4-
use syn::{parse_quote, ItemTrait, Result, TraitItem};
4+
use syn::{ItemTrait, Result, TraitItem, parse_quote};
55

66
/// When added to a trait declaration, generates the impls required to use that trait in queries.
77
///

bevy-trait-query/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "bevy-trait-query"
3-
version = "0.7.0"
4-
edition = "2021"
3+
version = "0.16.0"
4+
edition.workspace = true
55

66
description = "Implementation of trait queries for the bevy game engine"
77
repository = "https://github.com/JoJoJet/bevy-trait-query/"

bevy-trait-query/src/all/core/read.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use bevy_ecs::{
66
storage::{SparseSets, Table, TableRow},
77
};
88

9-
use crate::{zip_exact, TraitImplMeta, TraitImplRegistry, TraitQuery};
9+
use crate::{TraitImplMeta, TraitImplRegistry, TraitQuery, zip_exact};
1010

1111
/// Read-access to all components implementing a trait for a given entity.
1212
///
@@ -187,13 +187,13 @@ impl<'w, Trait: ?Sized + TraitQuery> ReadTraits<'w, Trait> {
187187

188188
/// Returns an iterator over the components implementing `Trait` for the current entity
189189
/// that were added since the last time the system was run.
190-
pub fn iter_added(&self) -> impl Iterator<Item = Ref<'w, Trait>> {
190+
pub fn iter_added(&self) -> impl Iterator<Item = Ref<'w, Trait>> + use<'w, Trait> {
191191
self.iter().filter(DetectChanges::is_added)
192192
}
193193

194194
/// Returns an iterator over the components implementing `Trait` for the current entity
195195
/// whose values were changed since the last time the system was run.
196-
pub fn iter_changed(&self) -> impl Iterator<Item = Ref<'w, Trait>> {
196+
pub fn iter_changed(&self) -> impl Iterator<Item = Ref<'w, Trait>> + use<'w, Trait> {
197197
self.iter().filter(DetectChanges::is_changed)
198198
}
199199
}

bevy-trait-query/src/all/core/write.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use bevy_ecs::{
77
};
88

99
use crate::{
10-
zip_exact, CombinedReadTraitsIter, ReadSparseTraitsIter, ReadTableTraitsIter, TraitImplMeta,
11-
TraitImplRegistry, TraitQuery,
10+
CombinedReadTraitsIter, ReadSparseTraitsIter, ReadTableTraitsIter, TraitImplMeta,
11+
TraitImplRegistry, TraitQuery, zip_exact,
1212
};
1313

1414
/// Write-access to all components implementing a trait for a given entity.

bevy-trait-query/src/all/impls/all.rs

Lines changed: 35 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ use bevy_ecs::{
33
entity::Entity,
44
query::{QueryData, QueryItem, ReadOnlyQueryData, WorldQuery},
55
storage::TableRow,
6-
world::{unsafe_world_cell::UnsafeWorldCell, World},
6+
world::{World, unsafe_world_cell::UnsafeWorldCell},
77
};
88

99
use crate::{
10-
debug_unreachable, trait_registry_error, AllTraitsFetch, ReadTraits, TraitQuery,
11-
TraitQueryState, WriteTraits,
10+
AllTraitsFetch, ReadTraits, TraitQuery, TraitQueryState, WriteTraits, debug_unreachable,
11+
trait_registry_error,
1212
};
1313

1414
/// [`WorldQuery`] adapter that fetches all implementations of a given trait for an entity.
@@ -44,7 +44,9 @@ unsafe impl<Trait: ?Sized + TraitQuery> QueryData for All<&Trait> {
4444
_entity: Entity,
4545
table_row: TableRow,
4646
) -> Self::Item<'w> {
47-
let table = fetch.table.unwrap_or_else(|| debug_unreachable());
47+
let table = fetch
48+
.table
49+
.unwrap_or_else(|| unsafe { debug_unreachable() });
4850

4951
ReadTraits {
5052
registry: fetch.registry,
@@ -72,14 +74,16 @@ unsafe impl<Trait: ?Sized + TraitQuery> WorldQuery for All<&Trait> {
7274
last_run: Tick,
7375
this_run: Tick,
7476
) -> Self::Fetch<'w> {
75-
AllTraitsFetch {
76-
registry: world
77-
.get_resource()
78-
.unwrap_or_else(|| trait_registry_error()),
79-
table: None,
80-
sparse_sets: &world.storages().sparse_sets,
81-
last_run,
82-
this_run,
77+
unsafe {
78+
AllTraitsFetch {
79+
registry: world
80+
.get_resource()
81+
.unwrap_or_else(|| trait_registry_error()),
82+
table: None,
83+
sparse_sets: &world.storages().sparse_sets,
84+
last_run,
85+
this_run,
86+
}
8387
}
8488
}
8589

@@ -138,7 +142,9 @@ unsafe impl<Trait: ?Sized + TraitQuery> WorldQuery for All<&Trait> {
138142
#[inline]
139143
fn get_state(_: &Components) -> Option<Self::State> {
140144
// TODO: fix this https://github.com/bevyengine/bevy/issues/13798
141-
panic!("transmuting and any other operations concerning the state of a query are currently broken and shouldn't be used. See https://github.com/JoJoJet/bevy-trait-query/issues/59");
145+
panic!(
146+
"transmuting and any other operations concerning the state of a query are currently broken and shouldn't be used. See https://github.com/JoJoJet/bevy-trait-query/issues/59"
147+
);
142148
}
143149

144150
#[inline]
@@ -173,7 +179,9 @@ unsafe impl<'a, Trait: ?Sized + TraitQuery> QueryData for All<&'a mut Trait> {
173179
_entity: Entity,
174180
table_row: TableRow,
175181
) -> Self::Item<'w> {
176-
let table = fetch.table.unwrap_or_else(|| debug_unreachable());
182+
let table = fetch
183+
.table
184+
.unwrap_or_else(|| unsafe { debug_unreachable() });
177185

178186
WriteTraits {
179187
registry: fetch.registry,
@@ -200,14 +208,16 @@ unsafe impl<Trait: ?Sized + TraitQuery> WorldQuery for All<&mut Trait> {
200208
last_run: Tick,
201209
this_run: Tick,
202210
) -> Self::Fetch<'w> {
203-
AllTraitsFetch {
204-
registry: world
205-
.get_resource()
206-
.unwrap_or_else(|| trait_registry_error()),
207-
table: None,
208-
sparse_sets: &world.storages().sparse_sets,
209-
last_run,
210-
this_run,
211+
unsafe {
212+
AllTraitsFetch {
213+
registry: world
214+
.get_resource()
215+
.unwrap_or_else(|| trait_registry_error()),
216+
table: None,
217+
sparse_sets: &world.storages().sparse_sets,
218+
last_run,
219+
this_run,
220+
}
211221
}
212222
}
213223

@@ -267,7 +277,9 @@ unsafe impl<Trait: ?Sized + TraitQuery> WorldQuery for All<&mut Trait> {
267277
#[inline]
268278
fn get_state(_: &Components) -> Option<Self::State> {
269279
// TODO: fix this https://github.com/bevyengine/bevy/issues/13798
270-
panic!("transmuting and any other operations concerning the state of a query are currently broken and shouldn't be used. See https://github.com/JoJoJet/bevy-trait-query/issues/59");
280+
panic!(
281+
"transmuting and any other operations concerning the state of a query are currently broken and shouldn't be used. See https://github.com/JoJoJet/bevy-trait-query/issues/59"
282+
);
271283
}
272284

273285
#[inline]

bevy-trait-query/src/internal/dyn_constructor.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ impl<T: ?Sized> Clone for DynCtor<T> {
1616
impl<Trait: ?Sized> DynCtor<Trait> {
1717
#[inline]
1818
pub(crate) unsafe fn cast(self, ptr: Ptr) -> &Trait {
19-
&*(self.cast)(ptr.as_ptr())
19+
unsafe { &*(self.cast)(ptr.as_ptr()) }
2020
}
2121
#[inline]
2222
pub(crate) unsafe fn cast_mut(self, ptr: PtrMut) -> &mut Trait {
23-
&mut *(self.cast)(ptr.as_ptr())
23+
unsafe { &mut *(self.cast)(ptr.as_ptr()) }
2424
}
2525
}

bevy-trait-query/src/internal/register_ext.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::{
2-
dyn_constructor::DynCtor, TraitImplMeta, TraitImplRegistry, TraitQuery, TraitQueryMarker,
2+
TraitImplMeta, TraitImplRegistry, TraitQuery, TraitQueryMarker, dyn_constructor::DynCtor,
33
};
44
use bevy_ecs::prelude::{Component, World};
55

bevy-trait-query/src/internal/trait_registry.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use crate::dyn_constructor::DynCtor;
21
use crate::TraitQuery;
2+
use crate::dyn_constructor::DynCtor;
33
use bevy_ecs::component::{Component, ComponentId, StorageType};
44
use bevy_ecs::prelude::Resource;
55
#[derive(Resource)]

bevy-trait-query/src/internal/trait_state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use bevy_ecs::component::ComponentId;
22
use bevy_ecs::prelude::World;
33

44
use crate::{
5-
trait_registry::{TraitImplMeta, TraitImplRegistry},
65
TraitQuery,
6+
trait_registry::{TraitImplMeta, TraitImplRegistry},
77
};
88

99
#[doc(hidden)]

bevy-trait-query/src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ pub mod imports {
284284
ReadOnlyQueryData, WorldQuery,
285285
},
286286
storage::{Table, TableRow},
287-
world::{unsafe_world_cell::UnsafeWorldCell, World},
287+
world::{World, unsafe_world_cell::UnsafeWorldCell},
288288
};
289289
}
290290

@@ -301,5 +301,7 @@ unsafe fn debug_unreachable() -> ! {
301301
#[inline(never)]
302302
#[cold]
303303
fn trait_registry_error() -> ! {
304-
panic!("The trait query registry has not been initialized; did you forget to register your traits with the world?")
304+
panic!(
305+
"The trait query registry has not been initialized; did you forget to register your traits with the world?"
306+
)
305307
}

0 commit comments

Comments
 (0)