Skip to content

Commit 36da299

Browse files
committed
make Allocator object-safe
add test to ensure object-safety This allows for runtime polymorphic allocators
1 parent 9d43b32 commit 36da299

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

core/src/alloc/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,10 @@ pub unsafe trait Allocator {
342342
///
343343
/// The returned adaptor also implements `Allocator` and will simply borrow this.
344344
#[inline(always)]
345-
fn by_ref(&self) -> &Self {
345+
fn by_ref(&self) -> &Self
346+
where
347+
Self: Sized,
348+
{
346349
self
347350
}
348351
}

0 commit comments

Comments
 (0)