Commit 522f4e1 1 parent 5670d04 commit 522f4e1 Copy full SHA for 522f4e1
File tree 1 file changed +21
-0
lines changed
1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -584,6 +584,27 @@ impl<P: DerefMut> Pin<P> {
584
584
/// the pointee cannot move after `Pin<Pointer<T>>` got created.
585
585
/// "Malicious" implementations of `Pointer::DerefMut` are likewise
586
586
/// ruled out by the contract of `Pin::new_unchecked`.
587
+ ///
588
+ /// This method is useful when doing multiple calls to functions that consume the pinned type.
589
+ ///
590
+ /// # Examples
591
+ ///
592
+ /// ```
593
+ /// use std::pin::Pin;
594
+ ///
595
+ /// # struct Type {}
596
+ /// impl Type {
597
+ /// fn method(self: Pin<&mut Self>) {
598
+ /// // do something
599
+ /// }
600
+ ///
601
+ /// fn call_method_twice(mut self: Pin<&mut Self>) {
602
+ /// // `method` consumes `self`, so reborrow the `Pin<&mut Self>` via `as_mut`.
603
+ /// self.as_mut().method();
604
+ /// self.as_mut().method();
605
+ /// }
606
+ /// }
607
+ /// ```
587
608
#[ stable( feature = "pin" , since = "1.33.0" ) ]
588
609
#[ inline( always) ]
589
610
pub fn as_mut ( & mut self ) -> Pin < & mut P :: Target > {
You can’t perform that action at this time.
0 commit comments