about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTyler Mandry <tmandry@gmail.com>2019-10-15 16:08:00 -0700
committerGitHub <noreply@github.com>2019-10-15 16:08:00 -0700
commit3182f73e8dcce702bbfd330a28c9a35610d0af8e (patch)
tree0bfed6eb4c88f90e5fb9d035e08890279a903b0f
parentef5420301d4b9e03d9b845b82eadfda8e7398f83 (diff)
parentfa3a4aeae5f3a4c403bf07038c56e74df3d9df70 (diff)
downloadrust-3182f73e8dcce702bbfd330a28c9a35610d0af8e.tar.gz
rust-3182f73e8dcce702bbfd330a28c9a35610d0af8e.zip
Rollup merge of #65444 - spastorino:as-ref-for-list, r=Mark-Simulacrum
Implement AsRef<[T]> for List<T>

r? @Mark-Simulacrum
-rw-r--r--src/librustc/ty/mod.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs
index 00b5fa23047..65aea7b459f 100644
--- a/src/librustc/ty/mod.rs
+++ b/src/librustc/ty/mod.rs
@@ -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)
         }