Skip to content

Commit

Permalink
Rollup merge of rust-lang#65444 - spastorino:as-ref-for-list, r=Mark-…
Browse files Browse the repository at this point in the history
…Simulacrum

Implement AsRef<[T]> for List<T>

r? @Mark-Simulacrum
  • Loading branch information
Centril authored Oct 15, 2019
2 parents 4ba1658 + fa3a4ae commit 9ce03a6
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 9ce03a6

Please sign in to comment.