use bndpresbufch::Builder; #[test] fn wait() { // Create a queue that can hold at most 4 bytes of data let (tx, rx) = Builder::new().max_size(4).build(); // Fill queue up with 4 1-byte nodes for idx in 0..4 { tx.try_push([idx].into()).unwrap(); } // Pull managed node off queue let n = rx.pop_managed().unwrap(); assert_eq!(&*n, vec![0]); // Drop node, which should put it back in the channel drop(n); // Should get [0] again assert_eq!(rx.pop(), Some(vec![0])); } #[test] fn try_pop() { // Create a queue that can hold at most 4 bytes of data let (tx, rx) = Builder::new().max_size(4).build(); // Fill queue up with 4 1-byte nodes for idx in 0..4 { tx.try_push([idx].into()).unwrap(); } // Pull managed node off queue let n = rx.try_pop_managed().unwrap().unwrap(); assert_eq!(&*n, vec![0]); // Drop node, which should put it back in the channel drop(n); // Should get [0] again assert_eq!(rx.pop(), Some(vec![0])); } // vim: set ft=rust et sw=2 ts=2 sts=2 cinoptions=2 tw=79 :