Skip to content

Commit f30e1b1

Browse files
zicklagTekhnaeRaav
andauthored
fix: fix clippy lints. (#509)
Co-authored-by: Tekhnae Raav <tekhnaeraav@katharostech.com>
1 parent 5cf6ee1 commit f30e1b1

File tree

18 files changed

+120
-109
lines changed

18 files changed

+120
-109
lines changed

framework_crates/bones_asset/src/asset.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ pub struct AssetLoc {
217217

218218
impl AssetLoc {
219219
/// Borrow as an [`AssetLocRef`].
220-
pub fn as_ref(&self) -> AssetLocRef {
220+
pub fn as_ref(&self) -> AssetLocRef<'_> {
221221
AssetLocRef {
222222
pack: self.pack.as_deref(),
223223
path: &self.path,

framework_crates/bones_asset/src/server.rs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ impl AssetServer {
806806
}
807807

808808
/// Borrow a [`LoadedAsset`] associated to the given handle.
809-
pub fn get_asset_untyped(&self, handle: UntypedHandle) -> Option<MapRef<Cid, LoadedAsset>> {
809+
pub fn get_asset_untyped(&self, handle: UntypedHandle) -> Option<MapRef<'_, Cid, LoadedAsset>> {
810810
let cid = self.store.asset_ids.get(&handle)?;
811811
self.store.assets.get(&cid)
812812
}
@@ -815,7 +815,7 @@ impl AssetServer {
815815
pub fn get_asset_untyped_mut(
816816
&self,
817817
handle: UntypedHandle,
818-
) -> Option<MapRefMut<Cid, LoadedAsset>> {
818+
) -> Option<MapRefMut<'_, Cid, LoadedAsset>> {
819819
let cid = self.store.asset_ids.get(&handle)?;
820820
self.store.assets.get_mut(&cid)
821821
}
@@ -826,17 +826,17 @@ impl AssetServer {
826826
///
827827
/// Panics if the assets have not be loaded yet with [`AssetServer::load_assets`].
828828
#[track_caller]
829-
pub fn core(&self) -> MappedMutexGuard<AssetPack> {
829+
pub fn core(&self) -> MappedMutexGuard<'_, AssetPack> {
830830
MutexGuard::map(self.store.core_pack.lock(), |x| x.as_mut().unwrap())
831831
}
832832

833833
/// Get the core asset pack's root asset.
834-
pub fn root<T: HasSchema>(&self) -> MappedMapRef<Cid, LoadedAsset, T> {
834+
pub fn root<T: HasSchema>(&self) -> MappedMapRef<'_, Cid, LoadedAsset, T> {
835835
self.get(self.core().root.typed())
836836
}
837837

838838
/// Get the core asset pack's root asset as a type-erased [`SchemaBox`].
839-
pub fn untyped_root(&self) -> MappedMapRef<Cid, LoadedAsset, SchemaBox> {
839+
pub fn untyped_root(&self) -> MappedMapRef<'_, Cid, LoadedAsset, SchemaBox> {
840840
self.get_untyped(self.core().root)
841841
}
842842

@@ -852,7 +852,7 @@ impl AssetServer {
852852
/// Panics if the asset is not loaded or if the asset with the given handle doesn't have a
853853
/// schema matching `T`.
854854
#[track_caller]
855-
pub fn get<T: HasSchema>(&self, handle: Handle<T>) -> MappedMapRef<Cid, LoadedAsset, T> {
855+
pub fn get<T: HasSchema>(&self, handle: Handle<T>) -> MappedMapRef<'_, Cid, LoadedAsset, T> {
856856
self.try_get(handle)
857857
.expect("asset not found (handle has no cid)")
858858
.expect("asset does not have matching schema for given type")
@@ -864,7 +864,10 @@ impl AssetServer {
864864
///
865865
/// Panics if the asset is not loaded.
866866
#[track_caller]
867-
pub fn get_untyped(&self, handle: UntypedHandle) -> MappedMapRef<Cid, LoadedAsset, SchemaBox> {
867+
pub fn get_untyped(
868+
&self,
869+
handle: UntypedHandle,
870+
) -> MappedMapRef<'_, Cid, LoadedAsset, SchemaBox> {
868871
self.try_get_untyped(handle).unwrap()
869872
}
870873

@@ -877,7 +880,7 @@ impl AssetServer {
877880
pub fn get_untyped_mut(
878881
&self,
879882
handle: UntypedHandle,
880-
) -> MappedMapRefMut<Cid, LoadedAsset, SchemaBox> {
883+
) -> MappedMapRefMut<'_, Cid, LoadedAsset, SchemaBox> {
881884
self.try_get_untyped_mut(handle).unwrap()
882885
}
883886

@@ -918,7 +921,7 @@ impl AssetServer {
918921
pub fn try_get_untyped(
919922
&self,
920923
handle: UntypedHandle,
921-
) -> Option<MappedMapRef<Cid, LoadedAsset, SchemaBox>> {
924+
) -> Option<MappedMapRef<'_, Cid, LoadedAsset, SchemaBox>> {
922925
let cid = self.store.asset_ids.get(&handle)?;
923926
Some(MapRef::map(self.store.assets.get(&cid).unwrap(), |x| {
924927
&x.data
@@ -929,7 +932,7 @@ impl AssetServer {
929932
pub fn try_get_untyped_mut(
930933
&self,
931934
handle: UntypedHandle,
932-
) -> Option<MappedMapRefMut<Cid, LoadedAsset, SchemaBox>> {
935+
) -> Option<MappedMapRefMut<'_, Cid, LoadedAsset, SchemaBox>> {
933936
let cid = self.store.asset_ids.get_mut(&handle)?;
934937
Some(MapRefMut::map(
935938
self.store.assets.get_mut(&cid).unwrap(),
@@ -968,7 +971,7 @@ impl AssetServer {
968971
pub fn get_mut<T: HasSchema>(
969972
&mut self,
970973
handle: &Handle<T>,
971-
) -> MappedMapRefMut<Cid, LoadedAsset, T> {
974+
) -> MappedMapRefMut<'_, Cid, LoadedAsset, T> {
972975
let cid = self
973976
.store
974977
.asset_ids

framework_crates/bones_bevy_renderer/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ pub struct BonesBevyRenderer {
6767
pub struct BonesGame(pub bones::Game);
6868
impl BonesGame {
6969
/// Shorthand for [`bones::AssetServer`] typed access to the shared resource
70-
pub fn asset_server(&self) -> Option<bones::Ref<bones::AssetServer>> {
70+
pub fn asset_server(&self) -> Option<bones::Ref<'_, bones::AssetServer>> {
7171
self.0.shared_resource()
7272
}
7373
}

framework_crates/bones_ecs/src/components/typed.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -170,28 +170,28 @@ pub trait ComponentIterBitset<'a, T: HasSchema> {
170170
/// Iterates immutably over the components of this type where `bitset`
171171
/// indicates the indices of entities.
172172
/// Slower than `iter()` but allows joining between multiple component types.
173-
fn iter_with_bitset(&self, bitset: Rc<BitSetVec>) -> ComponentBitsetIterator<T>;
173+
fn iter_with_bitset(&self, bitset: Rc<BitSetVec>) -> ComponentBitsetIterator<'_, T>;
174174

175175
/// Iterates immutably over the components of this type where `bitset`
176176
/// indicates the indices of entities.
177177
/// Slower than `iter()` but allows joining between multiple component types.
178178
fn iter_with_bitset_optional(
179179
&self,
180180
bitset: Rc<BitSetVec>,
181-
) -> ComponentBitsetOptionalIterator<T>;
181+
) -> ComponentBitsetOptionalIterator<'_, T>;
182182

183183
/// Iterates mutable over the components of this type where `bitset`
184184
/// indicates the indices of entities.
185185
/// Slower than `iter()` but allows joining between multiple component types.
186-
fn iter_mut_with_bitset(&mut self, bitset: Rc<BitSetVec>) -> ComponentBitsetIteratorMut<T>;
186+
fn iter_mut_with_bitset(&mut self, bitset: Rc<BitSetVec>) -> ComponentBitsetIteratorMut<'_, T>;
187187

188188
/// Iterates mutably over the components of this type where `bitset`
189189
/// indicates the indices of entities.
190190
/// Slower than `iter()` but allows joining between multiple component types.
191191
fn iter_mut_with_bitset_optional(
192192
&mut self,
193193
bitset: Rc<BitSetVec>,
194-
) -> ComponentBitsetOptionalIteratorMut<T>;
194+
) -> ComponentBitsetOptionalIteratorMut<'_, T>;
195195

196196
/// Get bitset of [`ComponentStore`] / implementor.
197197
fn bitset(&self) -> &BitSetVec;
@@ -207,7 +207,7 @@ impl<'a, T: HasSchema> ComponentIterBitset<'a, T> for ComponentStore<T> {
207207
/// Gets an immutable reference to the component if there is exactly one instance of it.
208208
fn get_single_with_bitset(&self, bitset: Rc<BitSetVec>) -> Result<&T, QuerySingleError> {
209209
// SOUND: we know the schema matches.
210-
fn map<T>(r: SchemaRef) -> &T {
210+
fn map<T>(r: SchemaRef<'_>) -> &T {
211211
unsafe { r.cast_into_unchecked() }
212212
}
213213
self.untyped.get_single_with_bitset(bitset).map(map)
@@ -219,7 +219,7 @@ impl<'a, T: HasSchema> ComponentIterBitset<'a, T> for ComponentStore<T> {
219219
bitset: Rc<BitSetVec>,
220220
) -> Result<&mut T, QuerySingleError> {
221221
// SOUND: we know the schema matches.
222-
fn map<T>(r: SchemaRefMut) -> &mut T {
222+
fn map<T>(r: SchemaRefMut<'_>) -> &mut T {
223223
unsafe { r.cast_into_mut_unchecked() }
224224
}
225225
self.untyped.get_single_with_bitset_mut(bitset).map(map)
@@ -229,9 +229,9 @@ impl<'a, T: HasSchema> ComponentIterBitset<'a, T> for ComponentStore<T> {
229229
/// indicates the indices of entities.
230230
/// Slower than `iter()` but allows joining between multiple component types.
231231
#[inline]
232-
fn iter_with_bitset(&self, bitset: Rc<BitSetVec>) -> ComponentBitsetIterator<T> {
232+
fn iter_with_bitset(&self, bitset: Rc<BitSetVec>) -> ComponentBitsetIterator<'_, T> {
233233
// SOUND: we know the schema matches.
234-
fn map<T>(r: SchemaRef) -> &T {
234+
fn map<T>(r: SchemaRef<'_>) -> &T {
235235
unsafe { r.cast_into_unchecked() }
236236
}
237237
self.untyped.iter_with_bitset(bitset).map(map)
@@ -244,9 +244,9 @@ impl<'a, T: HasSchema> ComponentIterBitset<'a, T> for ComponentStore<T> {
244244
fn iter_with_bitset_optional(
245245
&self,
246246
bitset: Rc<BitSetVec>,
247-
) -> ComponentBitsetOptionalIterator<T> {
247+
) -> ComponentBitsetOptionalIterator<'_, T> {
248248
// SOUND: we know the schema matches.
249-
fn map<T>(r: Option<SchemaRef>) -> Option<&T> {
249+
fn map<T>(r: Option<SchemaRef<'_>>) -> Option<&T> {
250250
r.map(|r| unsafe { r.cast_into_unchecked() })
251251
}
252252
self.untyped.iter_with_bitset_optional(bitset).map(map)
@@ -256,9 +256,9 @@ impl<'a, T: HasSchema> ComponentIterBitset<'a, T> for ComponentStore<T> {
256256
/// indicates the indices of entities.
257257
/// Slower than `iter()` but allows joining between multiple component types.
258258
#[inline]
259-
fn iter_mut_with_bitset(&mut self, bitset: Rc<BitSetVec>) -> ComponentBitsetIteratorMut<T> {
259+
fn iter_mut_with_bitset(&mut self, bitset: Rc<BitSetVec>) -> ComponentBitsetIteratorMut<'_, T> {
260260
// SOUND: we know the schema matches.
261-
fn map<T>(r: SchemaRefMut) -> &mut T {
261+
fn map<T>(r: SchemaRefMut<'_>) -> &mut T {
262262
unsafe { r.cast_into_mut_unchecked() }
263263
}
264264

@@ -272,9 +272,9 @@ impl<'a, T: HasSchema> ComponentIterBitset<'a, T> for ComponentStore<T> {
272272
fn iter_mut_with_bitset_optional(
273273
&mut self,
274274
bitset: Rc<BitSetVec>,
275-
) -> ComponentBitsetOptionalIteratorMut<T> {
275+
) -> ComponentBitsetOptionalIteratorMut<'_, T> {
276276
// SOUND: we know the schema matches.
277-
fn map<T>(r: Option<SchemaRefMut>) -> Option<&mut T> {
277+
fn map<T>(r: Option<SchemaRefMut<'_>>) -> Option<&mut T> {
278278
r.map(|r| unsafe { r.cast_into_mut_unchecked() })
279279
}
280280
self.untyped.iter_mut_with_bitset_optional(bitset).map(map)

framework_crates/bones_ecs/src/components/untyped.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -250,12 +250,12 @@ impl UntypedComponentStore {
250250
/// Get a [`SchemaRef`] to the component for the given [`Entity`] if the entity has this
251251
/// component.
252252
#[inline]
253-
pub fn get_ref(&self, entity: Entity) -> Option<SchemaRef> {
253+
pub fn get_ref(&self, entity: Entity) -> Option<SchemaRef<'_>> {
254254
let idx = entity.index() as usize;
255255
self.get_idx(idx)
256256
}
257257

258-
fn get_idx(&self, idx: usize) -> Option<SchemaRef> {
258+
fn get_idx(&self, idx: usize) -> Option<SchemaRef<'_>> {
259259
if self.bitset.bit_test(idx) {
260260
// SOUND: we ensure that there is allocated storge for entities that have their bit set.
261261
let ptr = unsafe { self.storage.unchecked_idx(idx) };
@@ -377,7 +377,7 @@ impl UntypedComponentStore {
377377
pub fn get_many_ref_mut<const N: usize>(
378378
&mut self,
379379
entities: [Entity; N],
380-
) -> [Option<SchemaRefMut>; N] {
380+
) -> [Option<SchemaRefMut<'_>>; N] {
381381
// Sort a copy of the passed in entities list.
382382
let mut sorted = entities;
383383
sorted.sort_unstable();
@@ -494,7 +494,7 @@ impl UntypedComponentStore {
494494
pub fn get_single_with_bitset(
495495
&self,
496496
bitset: Rc<BitSetVec>,
497-
) -> Result<SchemaRef, QuerySingleError> {
497+
) -> Result<SchemaRef<'_>, QuerySingleError> {
498498
if self.bitset().bit_count() == 0 || bitset.bit_count() == 0 {
499499
// Both bitsets are empty so there are no matches
500500
return Err(QuerySingleError::NoEntities);
@@ -520,7 +520,7 @@ impl UntypedComponentStore {
520520
pub fn get_single_with_bitset_mut(
521521
&mut self,
522522
bitset: Rc<BitSetVec>,
523-
) -> Result<SchemaRefMut, QuerySingleError> {
523+
) -> Result<SchemaRefMut<'_>, QuerySingleError> {
524524
if self.bitset().bit_count() == 0 || bitset.bit_count() == 0 {
525525
// Both bitsets are empty so there are no matches
526526
return Err(QuerySingleError::NoEntities);
@@ -565,7 +565,7 @@ impl UntypedComponentStore {
565565
/// entities.
566566
///
567567
/// Slower than `iter()` but allows joining between multiple component types.
568-
pub fn iter_with_bitset(&self, bitset: Rc<BitSetVec>) -> UntypedComponentBitsetIterator {
568+
pub fn iter_with_bitset(&self, bitset: Rc<BitSetVec>) -> UntypedComponentBitsetIterator<'_> {
569569
UntypedComponentBitsetIterator {
570570
current_id: 0,
571571
components: self,
@@ -580,7 +580,7 @@ impl UntypedComponentStore {
580580
pub fn iter_mut_with_bitset(
581581
&mut self,
582582
bitset: Rc<BitSetVec>,
583-
) -> UntypedComponentBitsetIteratorMut {
583+
) -> UntypedComponentBitsetIteratorMut<'_> {
584584
UntypedComponentBitsetIteratorMut {
585585
current_id: 0,
586586
components: self,
@@ -593,7 +593,7 @@ impl UntypedComponentStore {
593593
pub fn iter_with_bitset_optional(
594594
&self,
595595
bitset: Rc<BitSetVec>,
596-
) -> UntypedComponentOptionalBitsetIterator {
596+
) -> UntypedComponentOptionalBitsetIterator<'_> {
597597
let components_count = self.bitset.bit_count();
598598
let query_count = bitset.bit_count();
599599
UntypedComponentOptionalBitsetIterator {
@@ -613,7 +613,7 @@ impl UntypedComponentStore {
613613
pub fn iter_mut_with_bitset_optional(
614614
&mut self,
615615
bitset: Rc<BitSetVec>,
616-
) -> UntypedComponentOptionalBitsetIteratorMut {
616+
) -> UntypedComponentOptionalBitsetIteratorMut<'_> {
617617
let components_count = self.bitset.bit_count();
618618
let query_count = bitset.bit_count();
619619
UntypedComponentOptionalBitsetIteratorMut {

framework_crates/bones_ecs/src/entities.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,10 @@ impl Entities {
610610
/// }
611611
/// }
612612
/// ```
613-
pub fn iter_with<Q: QueryItem>(&self, query: Q) -> EntitiesIterWith<<Q as QueryItem>::Iter> {
613+
pub fn iter_with<Q: QueryItem>(
614+
&self,
615+
query: Q,
616+
) -> EntitiesIterWith<'_, <Q as QueryItem>::Iter> {
614617
let mut bitset = self.bitset().clone();
615618
query.apply_bitset(&mut bitset);
616619
let bitset = Rc::new(bitset);
@@ -722,7 +725,7 @@ impl Entities {
722725
}
723726

724727
/// Iterates over all alive entities.
725-
pub fn iter(&self) -> EntityIterator {
728+
pub fn iter(&self) -> EntityIterator<'_> {
726729
EntityIterator {
727730
current_id: 0,
728731
next_id: self.next_id,

framework_crates/bones_ecs/src/resources.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ impl UntypedResource {
7575

7676
/// Borrow the resource.
7777
#[track_caller]
78-
pub fn borrow(&self) -> Ref<Option<SchemaBox>> {
78+
pub fn borrow(&self) -> Ref<'_, Option<SchemaBox>> {
7979
self.cell.borrow()
8080
}
8181

8282
/// Mutably borrow the resource.
8383
#[track_caller]
84-
pub fn borrow_mut(&self) -> RefMut<Option<SchemaBox>> {
84+
pub fn borrow_mut(&self) -> RefMut<'_, Option<SchemaBox>> {
8585
self.cell.borrow_mut()
8686
}
8787

@@ -253,7 +253,7 @@ impl Resources {
253253

254254
/// Borrow a resource.
255255
#[track_caller]
256-
pub fn get<T: HasSchema>(&self) -> Option<Ref<T>> {
256+
pub fn get<T: HasSchema>(&self) -> Option<Ref<'_, T>> {
257257
let b = self.untyped.get(T::schema()).borrow();
258258
if b.is_some() {
259259
Some(Ref::map(b, |b| unsafe {
@@ -266,7 +266,7 @@ impl Resources {
266266

267267
/// Borrow a resource.
268268
#[track_caller]
269-
pub fn get_mut<T: HasSchema>(&self) -> Option<RefMut<T>> {
269+
pub fn get_mut<T: HasSchema>(&self) -> Option<RefMut<'_, T>> {
270270
let b = self.untyped.get(T::schema()).borrow_mut();
271271
if b.is_some() {
272272
Some(RefMut::map(b, |b| unsafe {
@@ -373,7 +373,7 @@ impl<T: HasSchema> AtomicResource<T> {
373373
/// Lock the resource for reading.
374374
///
375375
/// This returns a read guard, very similar to an [`RwLock`][std::sync::RwLock].
376-
pub fn borrow(&self) -> Option<Ref<T>> {
376+
pub fn borrow(&self) -> Option<Ref<'_, T>> {
377377
let borrow = self.untyped.borrow();
378378
if borrow.is_some() {
379379
Some(Ref::map(borrow, |r| unsafe {
@@ -387,7 +387,7 @@ impl<T: HasSchema> AtomicResource<T> {
387387
/// Lock the resource for read-writing.
388388
///
389389
/// This returns a write guard, very similar to an [`RwLock`][std::sync::RwLock].
390-
pub fn borrow_mut(&self) -> Option<RefMut<T>> {
390+
pub fn borrow_mut(&self) -> Option<RefMut<'_, T>> {
391391
let borrow = self.untyped.borrow_mut();
392392
if borrow.is_some() {
393393
Some(RefMut::map(borrow, |r| unsafe {
@@ -415,7 +415,7 @@ impl<T: HasSchema + FromWorld> AtomicResource<T> {
415415

416416
/// Borrow the resource, initializing it if it doesn't exist.
417417
#[track_caller]
418-
pub fn init_borrow(&self, world: &World) -> Ref<T> {
418+
pub fn init_borrow(&self, world: &World) -> Ref<'_, T> {
419419
let map_borrow = |borrow| {
420420
// SOUND: we know the schema matches.
421421
Ref::map(borrow, |b: &Option<SchemaBox>| unsafe {
@@ -438,7 +438,7 @@ impl<T: HasSchema + FromWorld> AtomicResource<T> {
438438

439439
/// Borrow the resource, initializing it if it doesn't exist.
440440
#[track_caller]
441-
pub fn init_borrow_mut(&self, world: &World) -> RefMut<T> {
441+
pub fn init_borrow_mut(&self, world: &World) -> RefMut<'_, T> {
442442
let mut borrow = self.untyped.borrow_mut();
443443
if unlikely(borrow.is_none()) {
444444
*borrow = Some(SchemaBox::new(T::from_world(world)));
@@ -500,7 +500,7 @@ impl UntypedResourceSet {
500500

501501
/// Init resource with default, and return mutable ref for modification.
502502
/// If already exists, returns mutable ref to existing resource.
503-
pub fn init_resource<T: HasSchema + Default>(&mut self) -> RefMut<T> {
503+
pub fn init_resource<T: HasSchema + Default>(&mut self) -> RefMut<'_, T> {
504504
if !self.resources.iter().any(|x| x.schema() == T::schema()) {
505505
self.insert_resource(T::default());
506506
}
@@ -509,7 +509,7 @@ impl UntypedResourceSet {
509509

510510
/// Get mutable reference to startup resource if found.
511511
#[track_caller]
512-
pub fn resource_mut<T: HasSchema>(&self) -> Option<RefMut<T>> {
512+
pub fn resource_mut<T: HasSchema>(&self) -> Option<RefMut<'_, T>> {
513513
let res = self.resources.iter().find(|x| x.schema() == T::schema())?;
514514
let borrow = res.borrow_mut();
515515

0 commit comments

Comments
 (0)