Skip to content

Commit 932b151

Browse files
committed
Implement project_replace method.
1 parent aa32b9e commit 932b151

File tree

9 files changed

+387
-79
lines changed

9 files changed

+387
-79
lines changed

pin-project-internal/src/lib.rs

+17-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ mod project;
2626

2727
use proc_macro::TokenStream;
2828

29-
use utils::{Immutable, Mutable};
29+
use utils::{Immutable, Mutable, Owned};
3030

3131
/// An attribute that creates a projection struct covering all the fields.
3232
///
@@ -520,7 +520,7 @@ pub fn project(args: TokenStream, input: TokenStream) -> TokenStream {
520520
/// `project_ref` method.
521521
///
522522
/// This is the same as [`project`] attribute except it refers to the projected
523-
/// type returned by `project_ref` method.
523+
/// type returned by the `project_ref` method.
524524
///
525525
/// See [`project`] attribute for more details.
526526
///
@@ -531,6 +531,21 @@ pub fn project_ref(args: TokenStream, input: TokenStream) -> TokenStream {
531531
project::attribute(&args.into(), input, Immutable).into()
532532
}
533533

534+
/// An attribute to provide way to refer to the projected type returned by
535+
/// `project_replace` method.
536+
///
537+
/// This is the same as [`project`] attribute except it refers to the projected
538+
/// type returned by the `project_replace` method.
539+
///
540+
/// See [`project`] attribute for more details.
541+
///
542+
/// [`project`]: ./attr.project.html
543+
#[proc_macro_attribute]
544+
pub fn project_replace(args: TokenStream, input: TokenStream) -> TokenStream {
545+
let input = syn::parse_macro_input!(input);
546+
project::attribute(&args.into(), input, Owned).into()
547+
}
548+
534549
/// An internal helper macro.
535550
#[doc(hidden)]
536551
#[proc_macro_derive(__PinProjectInternalDerive, attributes(pin))]

0 commit comments

Comments
 (0)