Implement AsRef<[T]> for List<T>
This commit is contained in:
parent
e413dc36a8
commit
fa3a4aeae5
1 changed files with 7 additions and 0 deletions
|
@ -700,6 +700,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…
Add table
Reference in a new issue