Skip to content

Commit

Permalink
Adjust implementations of Reallocator to use Storage::forget
Browse files Browse the repository at this point in the history
  • Loading branch information
nickmertin committed Apr 7, 2024
1 parent 9c46724 commit 85c4db3
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/base/default_allocator.rs
Expand Up @@ -15,7 +15,7 @@ use crate::base::array_storage::ArrayStorage;
use crate::base::dimension::Dim;
#[cfg(any(feature = "alloc", feature = "std"))]
use crate::base::dimension::{DimName, Dyn};
use crate::base::storage::{RawStorage, RawStorageMut};
use crate::base::storage::{RawStorage, RawStorageMut, Storage};
#[cfg(any(feature = "std", feature = "alloc"))]
use crate::base::vec_storage::VecStorage;
use crate::base::Scalar;
Expand Down Expand Up @@ -206,8 +206,8 @@ where

// Safety:
// - We don’t care about dropping elements because the caller is responsible for dropping things.
// - We forget `buf` so that we don’t drop the other elements.
std::mem::forget(buf);
// - We forget `buf` so that we don’t drop the other elements, but ensure the buffer itself is cleaned up.
buf.forget();

res
}
Expand Down Expand Up @@ -238,7 +238,7 @@ where
// Safety:
// - We don’t care about dropping elements because the caller is responsible for dropping things.
// - We forget `buf` so that we don’t drop the other elements.
std::mem::forget(buf);
buf.forget();

res
}
Expand Down Expand Up @@ -269,7 +269,7 @@ where
// Safety:
// - We don’t care about dropping elements because the caller is responsible for dropping things.
// - We forget `buf` so that we don’t drop the other elements.
std::mem::forget(buf);
buf.forget();

res
}
Expand Down

0 comments on commit 85c4db3

Please sign in to comment.