Skip to content

Commit

Permalink
Rollup merge of #65444 - spastorino:as-ref-for-list, r=Mark-Simulacrum
Browse files Browse the repository at this point in the history
Implement AsRef<[T]> for List<T>

r? @Mark-Simulacrum
  • Loading branch information
Centril committed Oct 15, 2019
2 parents f46d291 + fa3a4ae commit 453d011
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 @@ -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)
}
Expand Down

0 comments on commit 453d011

Please sign in to comment.