From 0882f531117829b4411d003440fd119eaf627b7b Mon Sep 17 00:00:00 2001 From: Yaroslav Dynnikov <yaroslav.dynnikov@gmail.com> Date: Mon, 3 Oct 2022 22:42:20 +0300 Subject: [PATCH] doc: mailbox clone --- src/mailbox.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/mailbox.rs b/src/mailbox.rs index 9dc762920b..bed6d0bb10 100644 --- a/src/mailbox.rs +++ b/src/mailbox.rs @@ -57,6 +57,17 @@ struct Inner<T> { } impl<T> Clone for Mailbox<T> { + /// Shares access to the existing mailbox, thereby enabling + /// inter-fiber communication. The conent itself isn't cloned. + /// + /// # Example + /// ``` + /// let original: Mailbox<i32> = Mailbox::new(); + /// let cloned: Mailbox<i32> = original.clone(); + /// cloned.send(55); + /// assert_eq!(original.try_receive_all(), vec![55]); + /// ``` + /// fn clone(&self) -> Self { Self(self.0.clone()) } -- GitLab