Skip to content

Updating documentation and version #26

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

Merged
merged 3 commits into from
Apr 22, 2020
Merged
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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "pin-utils"
edition = "2018"
version = "0.1.0-alpha.4"
version = "0.1.0"
authors = ["Josef Brandl <[email protected]>"]
license = "MIT OR Apache-2.0"
readme = "README.md"
Expand Down
10 changes: 5 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
#![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-alpha.4")]
#![doc(html_root_url = "https://docs.rs/pin-utils/0.1.0")]

#[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 changes: 15 additions & 5 deletions src/projection.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
/// 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.
/// - If the struct wants to implement [`Unpin`], it has to do so conditionally:
/// 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;
Expand All @@ -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
Expand All @@ -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;
///
Expand All @@ -75,6 +80,11 @@ 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) => (
Expand Down
4 changes: 3 additions & 1 deletion src/stack_pin.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/// Pins a value on the stack.
///
/// ```
/// # Example
///
/// ```rust
/// # use pin_utils::pin_mut;
/// # use core::pin::Pin;
/// # struct Foo {}
Expand Down