File tree 1 file changed +26
-0
lines changed
1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -495,6 +495,19 @@ impl<T> Sender<T> {
495
495
}
496
496
497
497
/// Returns whether the senders belong to the same channel.
498
+ ///
499
+ /// # Examples
500
+ ///
501
+ /// ```
502
+ /// # futures_lite::future::block_on(async {
503
+ /// use async_channel::unbounded;
504
+ ///
505
+ /// let (s, r) = unbounded::<()>();
506
+ /// let s2 = s.clone();
507
+ ///
508
+ /// assert!(s.same_channel(&s2));
509
+ /// # });
510
+ /// ```
498
511
pub fn same_channel ( & self , other : & Sender < T > ) -> bool {
499
512
Arc :: ptr_eq ( & self . channel , & other. channel )
500
513
}
@@ -827,6 +840,19 @@ impl<T> Receiver<T> {
827
840
}
828
841
829
842
/// Returns whether the receivers belong to the same channel.
843
+ ///
844
+ /// # Examples
845
+ ///
846
+ /// ```
847
+ /// # futures_lite::future::block_on(async {
848
+ /// use async_channel::unbounded;
849
+ ///
850
+ /// let (s, r) = unbounded::<()>();
851
+ /// let r2 = r.clone();
852
+ ///
853
+ /// assert!(r.same_channel(&r2));
854
+ /// # });
855
+ /// ```
830
856
pub fn same_channel ( & self , other : & Receiver < T > ) -> bool {
831
857
Arc :: ptr_eq ( & self . channel , & other. channel )
832
858
}
You can’t perform that action at this time.
0 commit comments