Skip to content

Commit f786dc1

Browse files
hyykingcramertj
authored andcommitted
chore(lib): 0.1.0 release candidate. Using core library directly and clean up docs
1 parent 72d3f9c commit f786dc1

File tree

4 files changed

+30
-23
lines changed

4 files changed

+30
-23
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "pin-utils"
33
edition = "2018"
4-
version = "0.1.0-alpha.4"
4+
version = "0.1.0"
55
authors = ["Josef Brandl <[email protected]>"]
66
license = "MIT OR Apache-2.0"
77
readme = "README.md"

src/lib.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,9 @@
44
#![warn(missing_docs, missing_debug_implementations)]
55
#![deny(bare_trait_objects)]
66
#![allow(unknown_lints)]
7+
#![doc(html_root_url = "https://docs.rs/pin-utils/0.1.0")]
78

8-
#![doc(html_root_url = "https://docs.rs/pin-utils/0.1.0-alpha.4")]
9-
10-
#[doc(hidden)]
11-
pub mod core_reexport {
12-
#[doc(hidden)]
13-
pub use core::*;
14-
}
15-
16-
#[macro_use] mod stack_pin;
17-
#[macro_use] mod projection;
9+
#[macro_use]
10+
mod stack_pin;
11+
#[macro_use]
12+
mod projection;

src/projection.rs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
/// A pinned projection of a struct field.
22
///
3+
/// # Safety
4+
///
35
/// To make using this macro safe, three things need to be ensured:
46
/// - If the struct implements [`Drop`], the [`drop`] method is not allowed to
57
/// move the value of the field.
68
/// - If the struct wants to implement [`Unpin`], it has to do so conditionally:
79
/// The struct can only implement [`Unpin`] if the field's type is [`Unpin`].
810
/// - The struct must not be `#[repr(packed)]`.
911
///
10-
/// ```
12+
/// # Example
13+
///
14+
/// ```rust
1115
/// use pin_utils::unsafe_pinned;
1216
/// use std::marker::Unpin;
1317
/// use std::pin::Pin;
@@ -27,7 +31,7 @@
2731
/// impl<T: Unpin> Unpin for Foo<T> {} // Conditional Unpin impl
2832
/// ```
2933
///
30-
/// Note that borrowing the field multiple times requires using `.as_mut()` to
34+
/// Note: borrowing the field multiple times requires using `.as_mut()` to
3135
/// avoid consuming the `Pin`.
3236
///
3337
/// [`Unpin`]: core::marker::Unpin
@@ -37,10 +41,10 @@ macro_rules! unsafe_pinned {
3741
($f:tt: $t:ty) => (
3842
#[allow(unsafe_code)]
3943
fn $f<'__a>(
40-
self: $crate::core_reexport::pin::Pin<&'__a mut Self>
41-
) -> $crate::core_reexport::pin::Pin<&'__a mut $t> {
44+
self: ::core::pin::Pin<&'__a mut Self>
45+
) -> ::core::pin::Pin<&'__a mut $t> {
4246
unsafe {
43-
$crate::core_reexport::pin::Pin::map_unchecked_mut(
47+
::core::pin::Pin::map_unchecked_mut(
4448
self, |x| &mut x.$f
4549
)
4650
}
@@ -50,15 +54,16 @@ macro_rules! unsafe_pinned {
5054

5155
/// An unpinned projection of a struct field.
5256
///
57+
/// # Safety
58+
///
5359
/// This macro is unsafe because it creates a method that returns a normal
5460
/// non-pin reference to the struct field. It is up to the programmer to ensure
5561
/// that the contained value can be considered not pinned in the current
5662
/// context.
5763
///
58-
/// Note that borrowing the field multiple times requires using `.as_mut()` to
59-
/// avoid consuming the `Pin`.
64+
/// # Example
6065
///
61-
/// ```
66+
/// ```rust
6267
/// use pin_utils::unsafe_unpinned;
6368
/// use std::pin::Pin;
6469
///
@@ -75,15 +80,20 @@ macro_rules! unsafe_pinned {
7580
/// }
7681
/// }
7782
/// ```
83+
///
84+
/// Note: borrowing the field multiple times requires using `.as_mut()` to
85+
/// avoid consuming the [`Pin`].
86+
///
87+
/// [`Pin`]: core::pin::Pin
7888
#[macro_export]
7989
macro_rules! unsafe_unpinned {
8090
($f:tt: $t:ty) => (
8191
#[allow(unsafe_code)]
8292
fn $f<'__a>(
83-
self: $crate::core_reexport::pin::Pin<&'__a mut Self>
93+
self: ::core::pin::Pin<&'__a mut Self>
8494
) -> &'__a mut $t {
8595
unsafe {
86-
&mut $crate::core_reexport::pin::Pin::get_unchecked_mut(self).$f
96+
&mut ::core::pin::Pin::get_unchecked_mut(self).$f
8797
}
8898
}
8999
)

src/stack_pin.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/// Pins a value on the stack.
22
///
3-
/// ```
3+
/// # Example
4+
///
5+
/// ```rust
46
/// # use pin_utils::pin_mut;
57
/// # use core::pin::Pin;
68
/// # struct Foo {}
@@ -17,7 +19,7 @@ macro_rules! pin_mut {
1719
// ever again.
1820
#[allow(unused_mut)]
1921
let mut $x = unsafe {
20-
$crate::core_reexport::pin::Pin::new_unchecked(&mut $x)
22+
::core::pin::Pin::new_unchecked(&mut $x)
2123
};
2224
)* }
2325
}

0 commit comments

Comments
 (0)