From 0e785d9a007aed7bbcda01dea555d748e0fd6c67 Mon Sep 17 00:00:00 2001 From: Chris Morgan Date: Fri, 21 Nov 2014 15:32:45 +1100 Subject: [PATCH] impl BorrowFrom<&'static [T]> for [T] This is for symmetry with the str-based implementation and allows things like Map<&'static [u8], V> from rust-phf to work properly. --- src/libcore/borrow.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libcore/borrow.rs b/src/libcore/borrow.rs index f0a14c02382ee..ef22a1a951a27 100644 --- a/src/libcore/borrow.rs +++ b/src/libcore/borrow.rs @@ -73,6 +73,10 @@ impl BorrowFrom<&'static str> for str { fn borrow_from<'a>(owned: &'a &'static str) -> &'a str { &**owned } } +impl BorrowFrom<&'static [T]> for [T] { + fn borrow_from<'a>(owned: &'a &'static [T]) -> &'a [T] { &**owned } +} + /// A generalization of Clone to borrowed data. pub trait ToOwned for Sized?: BorrowFrom { /// Create owned data from borrowed data, usually by copying.