Skip to content

Commit

Permalink
Rephrase for clarity.
Browse files Browse the repository at this point in the history
  • Loading branch information
maueroats authored and tygyh committed Dec 29, 2023
1 parent 8067e46 commit f0c38bc
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions crates/bevy_ecs/src/entity/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,11 +440,13 @@ impl Entities {
// Use one atomic subtract to grab a range of new IDs. The range might be
// entirely nonnegative, meaning all IDs come from the freelist, or entirely
// negative, meaning they are all new IDs to allocate, or a mix of both.
#[allow(clippy::unnecessary_fallible_conversions)]
let range_end = self
.free_cursor
// Unwrap: these conversions can only fail on platforms that don't support 64-bit atomics
// and use AtomicIsize instead (see note on `IdCursor`).
.fetch_sub(IdCursor::try_from(count).unwrap(), Ordering::Relaxed);
#[allow(clippy::unnecessary_fallible_conversions)]
let range_start = range_end - IdCursor::try_from(count).unwrap();

let freelist_range = range_start.max(0) as usize..range_end.max(0) as usize;
Expand Down Expand Up @@ -633,6 +635,7 @@ impl Entities {
let freelist_size = *self.free_cursor.get_mut();
// Unwrap: these conversions can only fail on platforms that don't support 64-bit atomics
// and use AtomicIsize instead (see note on `IdCursor`).
#[allow(clippy::unnecessary_fallible_conversions)]
let shortfall = IdCursor::try_from(additional).unwrap() - freelist_size;
if shortfall > 0 {
self.meta.reserve(shortfall as usize);
Expand Down
1 change: 1 addition & 0 deletions crates/bevy_reflect/src/impls/std.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1295,6 +1295,7 @@ impl<T: FromReflect + Clone + TypePath> FromReflect for Cow<'static, [T]> {
for field in ref_list.iter() {
temp_vec.push(T::from_reflect(field)?);
}
#[allow(clippy::unnecessary_fallible_conversions)]
temp_vec.try_into().ok()
} else {
None
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ impl<V: Hash, H: BuildHasher + Default> Hashed<V, H> {
let mut hasher = builder.build_hasher();
value.hash(&mut hasher);
Self {
hash: hasher.finish(),
hash: builder.hash_one(&value),
value,
marker: PhantomData,
}
Expand Down
1 change: 1 addition & 0 deletions examples/3d/transmission.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ fn setup(
let plane_mesh = meshes.add(shape::Plane::from_size(2.0).into());

let cylinder_mesh = meshes.add(
#[allow(clippy::unnecessary_fallible_conversions)]
Mesh::try_from(shape::Cylinder {
radius: 0.5,
height: 2.0,
Expand Down
5 changes: 3 additions & 2 deletions examples/ecs/ecs_guide.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,9 @@ fn exclusive_player_system(world: &mut World) {
}

// Sometimes systems need to be stateful. Bevy's ECS provides the `Local` system parameter
// for this case. A `Local<T>` refers to a value owned by the system of type `T`, which is automatically
// initialized using `T`'s `FromWorld`* implementation. In this system's `Local` (`counter`), `T` is `u32`.
// for this case. A `Local<T>` refers to a value of type `T` that is owned by the system.
// This value is automatically initialized using `T`'s `FromWorld`* implementation.
// In this system's `Local` (`counter`), `T` is `u32`.
// Therefore, on the first turn, `counter` has a value of 0.
//
// *: `FromWorld` is a trait which creates a value using the contents of the `World`.
Expand Down

0 comments on commit f0c38bc

Please sign in to comment.