Skip to content

Commit

Permalink
Document features
Browse files Browse the repository at this point in the history
  • Loading branch information
djkoloski committed Aug 11, 2024
1 parent b2375d1 commit 7c005d7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ categories = ["no-std", "no-std::no-alloc"]

[workspace.dependencies]
proc-macro2 = { version = "1", default-features = false }
ptr_meta_derive = { version = "0.3.0-alpha.2", default-features = false, path = "ptr_meta_derive" }
ptr_meta_derive = { version = "=0.3.0-alpha.3", default-features = false, path = "ptr_meta_derive" }
syn = { version = "2", default-features = false }
quote = { version = "1", default-features = false }
16 changes: 11 additions & 5 deletions ptr_meta/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
//! `ptr_meta` provides inherent implementations for many builtin types:
//!
//! - All [`Sized`] types implement [`Pointee`] via a blanket implementation.
//! - `slice`s and `str`s
//! - `CStr` and `OsStr` (requires `std`)
//! - `slice`, `str`, and `CStr`
//! - `OsStr` (requires `std`)
//! - `dyn Any`, optionally with `+ Send` and/or `+ Sync`
//! - `dyn Error`, optionally with `+Send` and/or `+ Sync` (requires `std`)
//!
Expand Down Expand Up @@ -64,6 +64,12 @@
//!
//! Note that this will not produce implementations for `Trait + Send + Sync`.
//!
//! ## Features
//!
//! - `derive`: Re-exports the macros from `ptr_meta_derive`. Enabled by
//! default.
//! - `std`: Enables additional impls for `std` types. Enabled by default.
//!
//! ## Example
#![doc = include_str!("../example.md")]
#![deny(
Expand All @@ -86,6 +92,7 @@
mod impls;

use core::{
ffi::CStr,
fmt,
hash::{Hash, Hasher},
};
Expand Down Expand Up @@ -147,17 +154,16 @@ unsafe impl Pointee for str {
type Metadata = usize;
}

#[cfg(feature = "std")]
// SAFETY: `CStr` pointers have a `usize` representing the length of the
// C-string slice in bytes (nul included) as their metadata.
unsafe impl Pointee for ::std::ffi::CStr {
unsafe impl Pointee for CStr {
type Metadata = usize;
}

#[cfg(feature = "std")]
// SAFETY: `OsStr` pointers have a `usize` representing the length of the
// string in bytes as their metadata.
unsafe impl Pointee for ::std::ffi::OsStr {
unsafe impl Pointee for std::ffi::OsStr {
type Metadata = usize;
}

Expand Down
2 changes: 1 addition & 1 deletion ptr_meta_derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use self::attributes::Attributes;
///
/// Additional arguments can be specified using attributes.
///
/// `#[ptr_meta(...)]` takes the following arguments:
/// `#[ptr_meta(...)]` accepts the following arguments:
///
/// - `crate = ...`: Chooses an alternative crate path to import ptr_meta from.
#[proc_macro_derive(Pointee, attributes(ptr_meta))]
Expand Down

0 comments on commit 7c005d7

Please sign in to comment.