From fec703dac5b70cc08cf7bc37e9c19f6a964f3221 Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Tue, 13 Aug 2019 13:07:59 +0200 Subject: [PATCH] Add `PathBuf` to list of stably dereferencable things --- README.md | 1 + src/lib.rs | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/README.md b/README.md index 24fd4b0..b2a595a 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ Enable the "alloc" feature (with default-features disabled) to have this trait b * `alloc::rc::Rc` * `alloc::arc::Arc` * `alloc::string::String` +* `alloc::path::PathBuf` For example, this crate can be built with alloc support via the following command: `cargo build --no-default-features --features alloc` diff --git a/src/lib.rs b/src/lib.rs index c4272b8..994f0a5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -159,6 +159,11 @@ use std::string::String; #[cfg(all(not(feature = "std"), feature = "alloc"))] use alloc::string::String; +#[cfg(all(feature = "std", not(feature = "alloc")))] +use std::path::PathBuf; +#[cfg(all(not(feature = "std"), feature = "alloc"))] +use alloc::path::PathBuf; + #[cfg(feature = "std")] use std::sync::{MutexGuard, RwLockReadGuard, RwLockWriteGuard}; @@ -175,6 +180,8 @@ unsafe impl StableDeref for Box {} unsafe impl StableDeref for Vec {} #[cfg(any(feature = "std", feature = "alloc"))] unsafe impl StableDeref for String {} +#[cfg(any(feature = "std", feature = "alloc"))] +unsafe impl StableDeref for PathBuf {} #[cfg(any(feature = "std", feature = "alloc"))] unsafe impl StableDeref for Rc {}