Skip to content

Commit

Permalink
Implement AsRef<[T]> for List<T>
Browse files Browse the repository at this point in the history
  • Loading branch information
spastorino committed Oct 15, 2019
1 parent e413dc3 commit fa3a4ae
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/librustc/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit fa3a4ae

Please sign in to comment.