Skip to content

Commit 3182f73

Browse files
authored
Rollup merge of #65444 - spastorino:as-ref-for-list, r=Mark-Simulacrum
Implement AsRef<[T]> for List<T> r? @Mark-Simulacrum
2 parents ef54203 + fa3a4ae commit 3182f73

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/librustc/ty/mod.rs

+7
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,13 @@ impl<T> Deref for List<T> {
701701
type Target = [T];
702702
#[inline(always)]
703703
fn deref(&self) -> &[T] {
704+
self.as_ref()
705+
}
706+
}
707+
708+
impl<T> AsRef<[T]> for List<T> {
709+
#[inline(always)]
710+
fn as_ref(&self) -> &[T] {
704711
unsafe {
705712
slice::from_raw_parts(self.data.as_ptr(), self.len)
706713
}

0 commit comments

Comments
 (0)