Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PathBuf to list of stably dereferencable things #8

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
7 changes: 7 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -175,6 +180,8 @@ unsafe impl<T: ?Sized> StableDeref for Box<T> {}
unsafe impl<T> StableDeref for Vec<T> {}
#[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<T: ?Sized> StableDeref for Rc<T> {}
Expand Down