Skip to content

Commit

Permalink
Implement project_replace method.
Browse files Browse the repository at this point in the history
  • Loading branch information
Diggsey committed Apr 26, 2020
1 parent aa32b9e commit 1db85fa
Show file tree
Hide file tree
Showing 9 changed files with 441 additions and 87 deletions.
19 changes: 17 additions & 2 deletions pin-project-internal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ mod project;

use proc_macro::TokenStream;

use utils::{Immutable, Mutable};
use utils::{Immutable, Mutable, Owned};

/// An attribute that creates a projection struct covering all the fields.
///
Expand Down Expand Up @@ -520,7 +520,7 @@ pub fn project(args: TokenStream, input: TokenStream) -> TokenStream {
/// `project_ref` method.
///
/// This is the same as [`project`] attribute except it refers to the projected
/// type returned by `project_ref` method.
/// type returned by the `project_ref` method.
///
/// See [`project`] attribute for more details.
///
Expand All @@ -531,6 +531,21 @@ pub fn project_ref(args: TokenStream, input: TokenStream) -> TokenStream {
project::attribute(&args.into(), input, Immutable).into()
}

/// An attribute to provide way to refer to the projected type returned by
/// `project_replace` method.
///
/// This is the same as [`project`] attribute except it refers to the projected
/// type returned by the `project_replace` method.
///
/// See [`project`] attribute for more details.
///
/// [`project`]: ./attr.project.html
#[proc_macro_attribute]
pub fn project_replace(args: TokenStream, input: TokenStream) -> TokenStream {
let input = syn::parse_macro_input!(input);
project::attribute(&args.into(), input, Owned).into()
}

/// An internal helper macro.
#[doc(hidden)]
#[proc_macro_derive(__PinProjectInternalDerive, attributes(pin))]
Expand Down
Loading

0 comments on commit 1db85fa

Please sign in to comment.