File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 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> {
584584 /// the pointee cannot move after `Pin<Pointer<T>>` got created.
585585 /// "Malicious" implementations of `Pointer::DerefMut` are likewise
586586 /// 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+ /// # Example
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+ /// ```
587608 #[ stable( feature = "pin" , since = "1.33.0" ) ]
588609 #[ inline( always) ]
589610 pub fn as_mut ( & mut self ) -> Pin < & mut P :: Target > {
You can’t perform that action at this time.
0 commit comments