diff --git a/src/lib.rs b/src/lib.rs index 7ea9b85..987fb6d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -26,7 +26,7 @@ //! //! ## Example //! -//! ```rust,no_run +//! ```rust //! extern crate lru; //! //! use lru::LruCache; @@ -130,6 +130,20 @@ impl Borrow for KeyRef { } } +#[cfg(not(feature = "nightly"))] +impl Borrow for KeyRef { + fn borrow(&self) -> &str { + unsafe { &*self.k } + } +} + +#[cfg(not(feature = "nightly"))] +impl Borrow<[T]> for KeyRef> { + fn borrow(&self) -> &[T] { + unsafe { &*self.k } + } +} + // Struct used to hold a key value pair. Also contains references to previous and next entries // so we can maintain the entries in a linked list ordered by their use. struct LruEntry { @@ -1495,7 +1509,6 @@ mod tests { } #[test] - #[cfg(feature = "nightly")] fn test_get_with_borrow() { use alloc::string::String; @@ -1508,7 +1521,6 @@ mod tests { } #[test] - #[cfg(feature = "nightly")] fn test_get_mut_with_borrow() { use alloc::string::String;