@@ -21,12 +21,9 @@ mod utils;
21
21
22
22
mod pin_project;
23
23
mod pinned_drop;
24
- mod project;
25
24
26
25
use proc_macro:: TokenStream ;
27
26
28
- use crate :: utils:: ProjKind ;
29
-
30
27
/// An attribute that creates projection types covering all the fields of
31
28
/// struct or enum.
32
29
///
@@ -531,235 +528,6 @@ pub fn pinned_drop(args: TokenStream, input: TokenStream) -> TokenStream {
531
528
pinned_drop:: attribute ( & args. into ( ) , input) . into ( )
532
529
}
533
530
534
- /// (deprecated) An attribute to provide way to refer to the projected type returned by
535
- /// `project` method.
536
- ///
537
- /// **This attribute is deprecated. Consider naming projected type by passing
538
- /// `project` argument to `#[pin_project]` attribute instead, see [release note]
539
- /// for details**
540
- ///
541
- /// The following syntaxes are supported.
542
- ///
543
- /// # `let` bindings
544
- ///
545
- /// *The attribute at the expression position is not stable, so you need to use
546
- /// a dummy `#[project]` attribute for the function.*
547
- ///
548
- /// ## Examples
549
- ///
550
- /// ```rust
551
- /// # #![allow(deprecated)]
552
- /// use pin_project::{pin_project, project};
553
- /// use std::pin::Pin;
554
- ///
555
- /// #[pin_project]
556
- /// struct Foo<T, U> {
557
- /// #[pin]
558
- /// future: T,
559
- /// field: U,
560
- /// }
561
- ///
562
- /// impl<T, U> Foo<T, U> {
563
- /// #[project] // Nightly does not need a dummy attribute to the function.
564
- /// fn baz(self: Pin<&mut Self>) {
565
- /// #[project]
566
- /// let Foo { future, field } = self.project();
567
- ///
568
- /// let _: Pin<&mut T> = future;
569
- /// let _: &mut U = field;
570
- /// }
571
- /// }
572
- /// ```
573
- ///
574
- /// # `match` expressions
575
- ///
576
- /// *The attribute at the expression position is not stable, so you need to use
577
- /// a dummy `#[project]` attribute for the function.*
578
- ///
579
- /// ## Examples
580
- ///
581
- /// ```rust
582
- /// # #![allow(deprecated)]
583
- /// use pin_project::{pin_project, project};
584
- /// use std::pin::Pin;
585
- ///
586
- /// #[pin_project]
587
- /// enum Enum<A, B, C> {
588
- /// Tuple(#[pin] A, B),
589
- /// Struct { field: C },
590
- /// Unit,
591
- /// }
592
- ///
593
- /// impl<A, B, C> Enum<A, B, C> {
594
- /// #[project] // Nightly does not need a dummy attribute to the function.
595
- /// fn baz(self: Pin<&mut Self>) {
596
- /// #[project]
597
- /// match self.project() {
598
- /// Enum::Tuple(x, y) => {
599
- /// let _: Pin<&mut A> = x;
600
- /// let _: &mut B = y;
601
- /// }
602
- /// Enum::Struct { field } => {
603
- /// let _: &mut C = field;
604
- /// }
605
- /// Enum::Unit => {}
606
- /// }
607
- /// }
608
- /// }
609
- /// ```
610
- ///
611
- /// # `impl` blocks
612
- ///
613
- /// All methods and associated functions in `#[project] impl` block become
614
- /// methods of the projected type. If you want to implement methods on the
615
- /// original type, you need to create another (non-`#[project]`) `impl` block.
616
- ///
617
- /// To call a method implemented in `#[project] impl` block, you need to first
618
- /// get the projected-type with `let this = self.project();`.
619
- ///
620
- /// ## Examples
621
- ///
622
- /// ```rust
623
- /// # #![allow(deprecated)]
624
- /// use pin_project::{pin_project, project};
625
- /// use std::pin::Pin;
626
- ///
627
- /// #[pin_project]
628
- /// struct Foo<T, U> {
629
- /// #[pin]
630
- /// future: T,
631
- /// field: U,
632
- /// }
633
- ///
634
- /// // impl for the original type
635
- /// impl<T, U> Foo<T, U> {
636
- /// fn bar(self: Pin<&mut Self>) {
637
- /// self.project().baz()
638
- /// }
639
- /// }
640
- ///
641
- /// // impl for the projected type
642
- /// #[project]
643
- /// impl<T, U> Foo<T, U> {
644
- /// fn baz(self) {
645
- /// let Self { future, field } = self;
646
- ///
647
- /// let _: Pin<&mut T> = future;
648
- /// let _: &mut U = field;
649
- /// }
650
- /// }
651
- /// ```
652
- ///
653
- /// # `use` statements
654
- ///
655
- /// ## Examples
656
- ///
657
- /// ```rust
658
- /// # #![allow(deprecated)]
659
- /// # mod dox {
660
- /// use pin_project::pin_project;
661
- ///
662
- /// #[pin_project]
663
- /// struct Foo<A> {
664
- /// #[pin]
665
- /// field: A,
666
- /// }
667
- ///
668
- /// mod bar {
669
- /// use super::Foo;
670
- /// use pin_project::project;
671
- /// use std::pin::Pin;
672
- ///
673
- /// #[project]
674
- /// use super::Foo;
675
- ///
676
- /// #[project]
677
- /// fn baz<A>(foo: Pin<&mut Foo<A>>) {
678
- /// #[project]
679
- /// let Foo { field } = foo.project();
680
- /// let _: Pin<&mut A> = field;
681
- /// }
682
- /// }
683
- /// # }
684
- /// ```
685
- ///
686
- /// [release note]: https://github.com/taiki-e/pin-project/releases/tag/v0.4.21
687
- #[ cfg_attr(
688
- deprecated_proc_macro,
689
- deprecated(
690
- since = "0.4.21" ,
691
- note = "consider naming projected type by passing `project` \
692
- argument to #[pin_project] attribute instead, see release note \
693
- <https://github.com/taiki-e/pin-project/releases/tag/v0.4.21> \
694
- for details"
695
- )
696
- ) ]
697
- #[ proc_macro_attribute]
698
- pub fn project ( args : TokenStream , input : TokenStream ) -> TokenStream {
699
- let input = syn:: parse_macro_input!( input) ;
700
- project:: attribute ( & args. into ( ) , input, ProjKind :: Mutable ) . into ( )
701
- }
702
-
703
- /// (deprecated) An attribute to provide way to refer to the projected type returned by
704
- /// `project_ref` method.
705
- ///
706
- /// **This attribute is deprecated. Consider naming projected type by passing
707
- /// `project_ref` argument to `#[pin_project]` attribute instead, see [release note]
708
- /// for details**
709
- ///
710
- /// This is the same as [`#[project]`][`project`] attribute except it refers to
711
- /// the projected type returned by the `project_ref` method.
712
- ///
713
- /// See [`#[project]`][`project`] attribute for more details.
714
- ///
715
- /// [release note]: https://github.com/taiki-e/pin-project/releases/tag/v0.4.21
716
- /// [`project`]: ./attr.project.html
717
- #[ cfg_attr(
718
- deprecated_proc_macro,
719
- deprecated(
720
- since = "0.4.21" ,
721
- note = "consider naming projected type by passing `project_ref` \
722
- argument to #[pin_project] attribute instead, see release note \
723
- <https://github.com/taiki-e/pin-project/releases/tag/v0.4.21> \
724
- for details"
725
- )
726
- ) ]
727
- #[ proc_macro_attribute]
728
- pub fn project_ref ( args : TokenStream , input : TokenStream ) -> TokenStream {
729
- let input = syn:: parse_macro_input!( input) ;
730
- project:: attribute ( & args. into ( ) , input, ProjKind :: Immutable ) . into ( )
731
- }
732
-
733
- /// (deprecated) An attribute to provide way to refer to the projected type returned by
734
- /// `project_replace` method.
735
- ///
736
- /// **This attribute is deprecated. Consider naming projected type by passing
737
- /// `project_replace` argument to `#[pin_project]` attribute instead, see [release note]
738
- /// for details**
739
- ///
740
- /// This is the same as [`#[project]`][`project`] attribute except it refers to
741
- /// the projected type returned by the `project_replace` method.
742
- ///
743
- /// See [`#[project]`][`project`] attribute for more details.
744
- ///
745
- /// [release note]: https://github.com/taiki-e/pin-project/releases/tag/v0.4.21
746
- /// [`project`]: ./attr.project.html
747
- #[ cfg_attr(
748
- deprecated_proc_macro,
749
- deprecated(
750
- since = "0.4.21" ,
751
- note = "consider naming projected type by passing `project_replace` \
752
- argument to #[pin_project] attribute instead, see release note \
753
- <https://github.com/taiki-e/pin-project/releases/tag/v0.4.21> \
754
- for details"
755
- )
756
- ) ]
757
- #[ proc_macro_attribute]
758
- pub fn project_replace ( args : TokenStream , input : TokenStream ) -> TokenStream {
759
- let input = syn:: parse_macro_input!( input) ;
760
- project:: attribute ( & args. into ( ) , input, ProjKind :: Owned ) . into ( )
761
- }
762
-
763
531
// An internal helper macro. Not public API.
764
532
#[ doc( hidden) ]
765
533
#[ proc_macro_derive( __PinProjectInternalDerive, attributes( pin) ) ]
0 commit comments