mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
simplify std::mem references (#15315)
# Objective - Fixes #15314 ## Solution - Remove unnecessary usings and simplify references to those functions. ## Testing CI
This commit is contained in:
parent
612897becd
commit
1b8c1c1242
20 changed files with 13 additions and 24 deletions
|
@ -10,7 +10,7 @@ keywords = ["game", "engine", "gamedev", "graphics", "bevy"]
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
repository = "https://github.com/bevyengine/bevy"
|
repository = "https://github.com/bevyengine/bevy"
|
||||||
documentation = "https://docs.rs/bevy"
|
documentation = "https://docs.rs/bevy"
|
||||||
rust-version = "1.79.0"
|
rust-version = "1.80.0"
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
exclude = [
|
exclude = [
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
use std::mem::size_of;
|
|
||||||
|
|
||||||
use bevy_ecs::{
|
use bevy_ecs::{
|
||||||
component::Component,
|
component::Component,
|
||||||
entity::Entity,
|
entity::Entity,
|
||||||
|
|
|
@ -1115,7 +1115,7 @@ impl Termination for AppExit {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use std::{iter, marker::PhantomData, mem::size_of, sync::Mutex};
|
use std::{iter, marker::PhantomData, sync::Mutex};
|
||||||
|
|
||||||
use bevy_ecs::{
|
use bevy_ecs::{
|
||||||
change_detection::{DetectChanges, ResMut},
|
change_detection::{DetectChanges, ResMut},
|
||||||
|
|
|
@ -26,7 +26,6 @@ use futures_io::{AsyncRead, AsyncSeek, AsyncWrite};
|
||||||
use futures_lite::{ready, Stream};
|
use futures_lite::{ready, Stream};
|
||||||
use std::{
|
use std::{
|
||||||
io::SeekFrom,
|
io::SeekFrom,
|
||||||
mem::size_of,
|
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
pin::Pin,
|
pin::Pin,
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
|
|
|
@ -1006,7 +1006,6 @@ impl EntityLocation {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use std::mem::size_of;
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn entity_niche_optimization() {
|
fn entity_niche_optimization() {
|
||||||
|
|
|
@ -505,7 +505,7 @@ mod tests {
|
||||||
use crate::{component::Component, ptr::OwningPtr, world::World};
|
use crate::{component::Component, ptr::OwningPtr, world::World};
|
||||||
|
|
||||||
use super::BlobVec;
|
use super::BlobVec;
|
||||||
use std::{alloc::Layout, cell::RefCell, mem::align_of, rc::Rc};
|
use std::{alloc::Layout, cell::RefCell, rc::Rc};
|
||||||
|
|
||||||
/// # Safety
|
/// # Safety
|
||||||
///
|
///
|
||||||
|
|
|
@ -2502,7 +2502,7 @@ impl World {
|
||||||
/// total += info.layout().size();
|
/// total += info.layout().size();
|
||||||
/// }
|
/// }
|
||||||
/// println!("Total size: {} bytes", total);
|
/// println!("Total size: {} bytes", total);
|
||||||
/// # assert_eq!(total, std::mem::size_of::<A>() + std::mem::size_of::<B>());
|
/// # assert_eq!(total, size_of::<A>() + size_of::<B>());
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// ## Dynamically running closures for resources matching specific `TypeId`s
|
/// ## Dynamically running closures for resources matching specific `TypeId`s
|
||||||
|
|
|
@ -13,7 +13,7 @@ use bevy_render::{
|
||||||
renderer::{RenderDevice, RenderQueue},
|
renderer::{RenderDevice, RenderQueue},
|
||||||
};
|
};
|
||||||
use bevy_utils::HashMap;
|
use bevy_utils::HashMap;
|
||||||
use std::{mem::size_of, ops::Range, sync::Arc};
|
use std::{ops::Range, sync::Arc};
|
||||||
|
|
||||||
/// Manages uploading [`MeshletMesh`] asset data to the GPU.
|
/// Manages uploading [`MeshletMesh`] asset data to the GPU.
|
||||||
#[derive(Resource)]
|
#[derive(Resource)]
|
||||||
|
|
|
@ -2,7 +2,7 @@ use super::{
|
||||||
asset::{Meshlet, MeshletBoundingSpheres},
|
asset::{Meshlet, MeshletBoundingSpheres},
|
||||||
persistent_buffer::PersistentGpuBufferable,
|
persistent_buffer::PersistentGpuBufferable,
|
||||||
};
|
};
|
||||||
use std::{mem::size_of, sync::Arc};
|
use std::sync::Arc;
|
||||||
|
|
||||||
const MESHLET_VERTEX_SIZE_IN_BYTES: u32 = 48;
|
const MESHLET_VERTEX_SIZE_IN_BYTES: u32 = 48;
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,6 @@ use binding_types::*;
|
||||||
use encase::internal::WriteInto;
|
use encase::internal::WriteInto;
|
||||||
use std::{
|
use std::{
|
||||||
array, iter,
|
array, iter,
|
||||||
mem::size_of,
|
|
||||||
sync::{atomic::AtomicBool, Arc},
|
sync::{atomic::AtomicBool, Arc},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@ use bevy_math::Mat4;
|
||||||
use bevy_render::{
|
use bevy_render::{
|
||||||
mesh::morph::MAX_MORPH_WEIGHTS, render_resource::*, renderer::RenderDevice, texture::GpuImage,
|
mesh::morph::MAX_MORPH_WEIGHTS, render_resource::*, renderer::RenderDevice, texture::GpuImage,
|
||||||
};
|
};
|
||||||
use std::mem::size_of;
|
|
||||||
|
|
||||||
use crate::render::skin::MAX_JOINTS;
|
use crate::render::skin::MAX_JOINTS;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use std::{iter, mem, mem::size_of};
|
use std::{iter, mem};
|
||||||
|
|
||||||
use bevy_ecs::entity::EntityHashMap;
|
use bevy_ecs::entity::EntityHashMap;
|
||||||
use bevy_ecs::prelude::*;
|
use bevy_ecs::prelude::*;
|
||||||
|
|
|
@ -603,7 +603,6 @@ trait DebugEnsureAligned {
|
||||||
impl<T: Sized> DebugEnsureAligned for *mut T {
|
impl<T: Sized> DebugEnsureAligned for *mut T {
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
fn debug_ensure_aligned(self) -> Self {
|
fn debug_ensure_aligned(self) -> Self {
|
||||||
use core::mem::align_of;
|
|
||||||
let align = align_of::<T>();
|
let align = align_of::<T>();
|
||||||
// Implementation shamelessly borrowed from the currently unstable
|
// Implementation shamelessly borrowed from the currently unstable
|
||||||
// ptr.is_aligned_to.
|
// ptr.is_aligned_to.
|
||||||
|
|
|
@ -11,7 +11,7 @@ use bevy_hierarchy::Children;
|
||||||
use bevy_math::Vec3;
|
use bevy_math::Vec3;
|
||||||
use bevy_reflect::prelude::*;
|
use bevy_reflect::prelude::*;
|
||||||
use bytemuck::{Pod, Zeroable};
|
use bytemuck::{Pod, Zeroable};
|
||||||
use std::{iter, mem::size_of};
|
use std::iter;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
const MAX_TEXTURE_WIDTH: u32 = 2048;
|
const MAX_TEXTURE_WIDTH: u32 = 2048;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use std::{iter, marker::PhantomData, mem::size_of};
|
use std::{iter, marker::PhantomData};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
render_resource::Buffer,
|
render_resource::Buffer,
|
||||||
|
@ -123,7 +123,7 @@ impl<T: NoUninit> RawBufferVec<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a [`Buffer`] on the [`RenderDevice`] with size
|
/// Creates a [`Buffer`] on the [`RenderDevice`] with size
|
||||||
/// at least `std::mem::size_of::<T>() * capacity`, unless a such a buffer already exists.
|
/// at least `size_of::<T>() * capacity`, unless a such a buffer already exists.
|
||||||
///
|
///
|
||||||
/// If a [`Buffer`] exists, but is too small, references to it will be discarded,
|
/// If a [`Buffer`] exists, but is too small, references to it will be discarded,
|
||||||
/// and a new [`Buffer`] will be created. Any previously created [`Buffer`]s
|
/// and a new [`Buffer`] will be created. Any previously created [`Buffer`]s
|
||||||
|
@ -302,7 +302,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a [`Buffer`] on the [`RenderDevice`] with size
|
/// Creates a [`Buffer`] on the [`RenderDevice`] with size
|
||||||
/// at least `std::mem::size_of::<T>() * capacity`, unless such a buffer already exists.
|
/// at least `size_of::<T>() * capacity`, unless such a buffer already exists.
|
||||||
///
|
///
|
||||||
/// If a [`Buffer`] exists, but is too small, references to it will be discarded,
|
/// If a [`Buffer`] exists, but is too small, references to it will be discarded,
|
||||||
/// and a new [`Buffer`] will be created. Any previously created [`Buffer`]s
|
/// and a new [`Buffer`] will be created. Any previously created [`Buffer`]s
|
||||||
|
|
|
@ -537,7 +537,6 @@ mod test {
|
||||||
use super::*;
|
use super::*;
|
||||||
use bevy_app::prelude::*;
|
use bevy_app::prelude::*;
|
||||||
use bevy_hierarchy::BuildChildren;
|
use bevy_hierarchy::BuildChildren;
|
||||||
use std::mem::size_of;
|
|
||||||
|
|
||||||
fn visibility_bundle(visibility: Visibility) -> VisibilityBundle {
|
fn visibility_bundle(visibility: Visibility) -> VisibilityBundle {
|
||||||
VisibilityBundle {
|
VisibilityBundle {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
//! This example show how you can create components dynamically, spawn entities with those components
|
//! This example show how you can create components dynamically, spawn entities with those components
|
||||||
//! as well as query for entities with those components.
|
//! as well as query for entities with those components.
|
||||||
|
|
||||||
use std::{alloc::Layout, io::Write, mem::size_of, ptr::NonNull};
|
use std::{alloc::Layout, io::Write, ptr::NonNull};
|
||||||
|
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy::{
|
use bevy::{
|
||||||
|
|
|
@ -36,7 +36,6 @@ use bevy::{
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use bytemuck::{Pod, Zeroable};
|
use bytemuck::{Pod, Zeroable};
|
||||||
use std::mem::size_of;
|
|
||||||
|
|
||||||
/// A marker component that represents an entity that is to be rendered using
|
/// A marker component that represents an entity that is to be rendered using
|
||||||
/// our custom phase item.
|
/// our custom phase item.
|
||||||
|
|
|
@ -17,7 +17,6 @@ use bevy::{
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use crossbeam_channel::{Receiver, Sender};
|
use crossbeam_channel::{Receiver, Sender};
|
||||||
use std::mem::size_of;
|
|
||||||
|
|
||||||
/// This example uses a shader source file from the assets subdirectory
|
/// This example uses a shader source file from the assets subdirectory
|
||||||
const SHADER_ASSET_PATH: &str = "shaders/gpu_readback.wgsl";
|
const SHADER_ASSET_PATH: &str = "shaders/gpu_readback.wgsl";
|
||||||
|
|
|
@ -27,7 +27,6 @@ use bevy::{
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use bytemuck::{Pod, Zeroable};
|
use bytemuck::{Pod, Zeroable};
|
||||||
use std::mem::size_of;
|
|
||||||
|
|
||||||
/// This example uses a shader source file from the assets subdirectory
|
/// This example uses a shader source file from the assets subdirectory
|
||||||
const SHADER_ASSET_PATH: &str = "shaders/instancing.wgsl";
|
const SHADER_ASSET_PATH: &str = "shaders/instancing.wgsl";
|
||||||
|
|
Loading…
Reference in a new issue