Skip to content

Commit

Permalink
T -> O
Browse files Browse the repository at this point in the history
  • Loading branch information
aumetra committed May 8, 2024
1 parent 50349ef commit 305b42c
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions packages/std/src/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ pub struct Borrowed;
///
/// This struct is crate internal since the cosmwasm-vm defines the same type independently.
#[repr(C)]
pub struct Region<T: Ownership> {
pub struct Region<O: Ownership> {
/// The beginning of the region expressed as bytes from the beginning of the linear memory
pub offset: u32,
/// The number of bytes available in this region
pub capacity: u32,
/// The number of bytes used in this region
pub length: u32,

_marker: PhantomData<T>,
_marker: PhantomData<O>,
}

impl Region<Borrowed> {
Expand Down Expand Up @@ -81,9 +81,9 @@ impl Region<Owned> {
}
}

impl<T> Region<T>
impl<O> Region<O>
where
T: Ownership,
O: Ownership,
{
unsafe fn from_parts(ptr: *const u8, capacity: usize, length: usize) -> Self {
// Well, this technically violates pointer provenance rules.
Expand Down Expand Up @@ -119,9 +119,9 @@ where
}
}

impl<T> Deref for Region<T>
impl<O> Deref for Region<O>
where
T: Ownership,
O: Ownership,
{
type Target = [u8];

Expand All @@ -130,13 +130,13 @@ where
}
}

impl<T> Drop for Region<T>
impl<O> Drop for Region<O>
where
T: Ownership,
O: Ownership,
{
fn drop(&mut self) {
// Since we can't specialize the drop impl we need to perform a runtime check
if TypeId::of::<T>() == TypeId::of::<Owned>() {
if TypeId::of::<O>() == TypeId::of::<Owned>() {
let region_start = self.offset as *mut u8;

// This case is explicitely disallowed by Vec
Expand Down

0 comments on commit 305b42c

Please sign in to comment.