chore(lib): 0.1.0 release candidate. Using core library directly and clean up docs

This commit is contained in:
hyyking
2019-11-08 12:14:33 +01:00
committed by Taylor Cramer
parent 5f387f8057
commit 5b11d88513
4 changed files with 30 additions and 23 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
[package]
name = "pin-utils"
edition = "2018"
version = "0.1.0-alpha.4"
version = "0.1.0"
authors = ["Josef Brandl <mail@josefbrandl.de>"]
license = "MIT OR Apache-2.0"
readme = "README.md"
+5 -10
View File
@@ -4,14 +4,9 @@
#![warn(missing_docs, missing_debug_implementations)]
#![deny(bare_trait_objects)]
#![allow(unknown_lints)]
#![doc(html_root_url = "https://docs.rs/pin-utils/0.1.0")]
#![doc(html_root_url = "https://docs.rs/pin-utils/0.1.0-alpha.4")]
#[doc(hidden)]
pub mod core_reexport {
#[doc(hidden)]
pub use core::*;
}
#[macro_use] mod stack_pin;
#[macro_use] mod projection;
#[macro_use]
mod stack_pin;
#[macro_use]
mod projection;
+20 -10
View File
@@ -1,5 +1,7 @@
/// A pinned projection of a struct field.
///
/// # Safety
///
/// To make using this macro safe, three things need to be ensured:
/// - If the struct implements [`Drop`], the [`drop`] method is not allowed to
/// move the value of the field.
@@ -7,7 +9,9 @@
/// The struct can only implement [`Unpin`] if the field's type is [`Unpin`].
/// - The struct must not be `#[repr(packed)]`.
///
/// ```
/// # Example
///
/// ```rust
/// use pin_utils::unsafe_pinned;
/// use std::marker::Unpin;
/// use std::pin::Pin;
@@ -27,7 +31,7 @@
/// impl<T: Unpin> Unpin for Foo<T> {} // Conditional Unpin impl
/// ```
///
/// Note that borrowing the field multiple times requires using `.as_mut()` to
/// Note: borrowing the field multiple times requires using `.as_mut()` to
/// avoid consuming the `Pin`.
///
/// [`Unpin`]: core::marker::Unpin
@@ -37,10 +41,10 @@ macro_rules! unsafe_pinned {
($f:tt: $t:ty) => (
#[allow(unsafe_code)]
fn $f<'__a>(
self: $crate::core_reexport::pin::Pin<&'__a mut Self>
) -> $crate::core_reexport::pin::Pin<&'__a mut $t> {
self: ::core::pin::Pin<&'__a mut Self>
) -> ::core::pin::Pin<&'__a mut $t> {
unsafe {
$crate::core_reexport::pin::Pin::map_unchecked_mut(
::core::pin::Pin::map_unchecked_mut(
self, |x| &mut x.$f
)
}
@@ -50,15 +54,16 @@ macro_rules! unsafe_pinned {
/// An unpinned projection of a struct field.
///
/// # Safety
///
/// This macro is unsafe because it creates a method that returns a normal
/// non-pin reference to the struct field. It is up to the programmer to ensure
/// that the contained value can be considered not pinned in the current
/// context.
///
/// Note that borrowing the field multiple times requires using `.as_mut()` to
/// avoid consuming the `Pin`.
/// # Example
///
/// ```
/// ```rust
/// use pin_utils::unsafe_unpinned;
/// use std::pin::Pin;
///
@@ -75,15 +80,20 @@ macro_rules! unsafe_pinned {
/// }
/// }
/// ```
///
/// Note: borrowing the field multiple times requires using `.as_mut()` to
/// avoid consuming the [`Pin`].
///
/// [`Pin`]: core::pin::Pin
#[macro_export]
macro_rules! unsafe_unpinned {
($f:tt: $t:ty) => (
#[allow(unsafe_code)]
fn $f<'__a>(
self: $crate::core_reexport::pin::Pin<&'__a mut Self>
self: ::core::pin::Pin<&'__a mut Self>
) -> &'__a mut $t {
unsafe {
&mut $crate::core_reexport::pin::Pin::get_unchecked_mut(self).$f
&mut ::core::pin::Pin::get_unchecked_mut(self).$f
}
}
)
+4 -2
View File
@@ -1,6 +1,8 @@
/// Pins a value on the stack.
///
/// ```
/// # Example
///
/// ```rust
/// # use pin_utils::pin_mut;
/// # use core::pin::Pin;
/// # struct Foo {}
@@ -17,7 +19,7 @@ macro_rules! pin_mut {
// ever again.
#[allow(unused_mut)]
let mut $x = unsafe {
$crate::core_reexport::pin::Pin::new_unchecked(&mut $x)
::core::pin::Pin::new_unchecked(&mut $x)
};
)* }
}