Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/vulkan/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use super::allocator;
use super::allocator::AllocationType;
use ash::vk;
use log::{debug, Level};
use core::marker::PhantomData;
use std::fmt;

use crate::{
Expand Down Expand Up @@ -177,7 +178,7 @@ impl Allocation {
/// See the note about safety in [the documentation of Allocation][Allocation#safety]
///
/// [`Slab`]: presser::Slab
pub fn try_as_mapped_slab(&mut self) -> Option<MappedAllocationSlab<'_>> {
pub fn try_as_mapped_slab<'a>(&'a mut self) -> Option<MappedAllocationSlab<'a>> {
let mapped_ptr = self.mapped_ptr()?.cast().as_ptr();

if self.size > isize::MAX as _ {
Expand All @@ -188,7 +189,7 @@ impl Allocation {
let size = self.size as usize;

Some(MappedAllocationSlab {
_borrowed_alloc: self,
_borrowed_alloc: PhantomData,
mapped_ptr,
size,
})
Expand Down Expand Up @@ -273,7 +274,7 @@ impl Default for Allocation {
///
/// This type should be acquired by calling [`Allocation::try_as_mapped_slab`].
pub struct MappedAllocationSlab<'a> {
_borrowed_alloc: &'a mut Allocation,
_borrowed_alloc: PhantomData<&'a mut Allocation>,
mapped_ptr: *mut u8,
size: usize,
}
Expand All @@ -298,13 +299,15 @@ unsafe impl presser::Slab for Allocation {
fn base_ptr(&self) -> *const u8 {
self.mapped_ptr
.expect("tried to use a non-mapped Allocation as a Slab")
.0
.as_ptr()
.cast()
}

fn base_ptr_mut(&mut self) -> *mut u8 {
self.mapped_ptr
.expect("tried to use a non-mapped Allocation as a Slab")
.0
.as_ptr()
.cast()
}
Expand Down