Rollup merge of #65444 - spastorino:as-ref-for-list, r=Mark-Simulacrum
Implement AsRef<[T]> for List<T> r? @Mark-Simulacrum
This commit is contained in:
commit
3182f73e8d
@ -701,6 +701,13 @@ impl<T> Deref for List<T> {
|
||||
type Target = [T];
|
||||
#[inline(always)]
|
||||
fn deref(&self) -> &[T] {
|
||||
self.as_ref()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> AsRef<[T]> for List<T> {
|
||||
#[inline(always)]
|
||||
fn as_ref(&self) -> &[T] {
|
||||
unsafe {
|
||||
slice::from_raw_parts(self.data.as_ptr(), self.len)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user