Skip to content

Commit

Permalink
refactor: Fix clippy warnings (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
MikuroXina authored Sep 21, 2023
1 parent b3db459 commit ec708f8
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ jobs:
- name: Create docs
if: matrix.os == 'ubuntu-latest'
run: cargo +nightly doc --features vendor,nightly,vulkan,simd_allocator,ttf,mixer --no-deps
- name: Publish test
if: matrix.os == 'ubuntu-latest'
working-directory: ./rich-sdl2-rust-sys
run: cargo publish --dry-run --features vendor

- uses: actions/upload-artifact@v3
if: matrix.os == 'ubuntu-latest'
Expand Down
2 changes: 1 addition & 1 deletion rich-sdl2-rust-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ fn include_paths(target_os: &str) -> impl Iterator<Item = PathBuf> {
.probe("sdl2")
.into_iter()
.flat_map(|sdl2| sdl2.include_paths)
.chain(std::env::var("SDL2_PATH").map(PathBuf::from).into_iter()),
.chain(std::env::var("SDL2_PATH").map(PathBuf::from)),
);
}
if cfg!(feature = "ttf") {
Expand Down
6 changes: 4 additions & 2 deletions src/audio/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,12 @@ impl<T: Default + Clone> AudioBuffer<T> {

fn as_u8_slice<T>(slice: &[T]) -> &[u8] {
let size = std::mem::size_of::<T>();
unsafe { std::slice::from_raw_parts(slice.as_ptr().cast(), slice.len() * size) }
unsafe { std::slice::from_raw_parts(slice.as_ptr().cast(), std::mem::size_of_val(slice)) }
}

fn as_u8_slice_mut<T>(slice: &mut [T]) -> &mut [u8] {
let size = std::mem::size_of::<T>();
unsafe { std::slice::from_raw_parts_mut(slice.as_mut_ptr().cast(), slice.len() * size) }
unsafe {
std::slice::from_raw_parts_mut(slice.as_mut_ptr().cast(), std::mem::size_of_val(slice))
}
}
2 changes: 1 addition & 1 deletion src/audio/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl<'device> QueuedAudio<'device> {
///
/// Returns `Err` if failed to queue `data`.
pub fn queue<T>(&self, data: &[T]) -> Result<()> {
let size = data.len() * std::mem::size_of::<T>();
let size = std::mem::size_of_val(data);
let ret =
unsafe { bind::SDL_QueueAudio(self.device.id, data.as_ptr().cast(), size as u32) };
if ret < 0 {
Expand Down
2 changes: 1 addition & 1 deletion src/mixer/chunk/channel/pause.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pub struct Pauser<'channel>(i32, PhantomData<&'channel mut Channel<'channel>>);

impl<'channel> Pauser<'channel> {
/// Pauses playing on the [`Channel`], or `None` if it is free.
pub fn pause(channel: &'channel mut Channel<'channel>) -> Option<Self> {
pub fn pause(channel: &'channel Channel<'channel>) -> Option<Self> {
if channel.0 == -1 {
return None;
}
Expand Down

0 comments on commit ec708f8

Please sign in to comment.