Add a method to test if split streams come from the same stream. (#1762)

* Add a method to test if split streams come from the same stream.

The exposed stream ID can also be used as key in associative containers.

* Document the fact that split stream IDs can dangle.
This commit is contained in:
Maarten de Vries
2020-01-20 19:50:31 -05:00
committed by Lucio Franco
parent 3176d0a48a
commit 5bf78d77ad
2 changed files with 51 additions and 1 deletions
+10
View File
@@ -45,6 +45,16 @@ fn is_send_and_sync() {
assert_bound::<WriteHalf<RW>>();
}
#[test]
fn split_stream_id() {
let (r1, w1) = split(RW);
let (r2, w2) = split(RW);
assert_eq!(r1.stream_id(), w1.stream_id());
assert_eq!(r1.stream_id(), w1.stream_id());
assert_ne!(r1.stream_id(), w2.stream_id());
assert_ne!(r2.stream_id(), w1.stream_id());
}
#[test]
fn unsplit_ok() {
let (r, w) = split(RW);