pub(crate) const EXP_POOL: &str = "pool is always put back when returning from functions that \
take it";
#[inline]
pub(crate) fn copy(dst: &mut [u8], src: &[u8]) -> usize {
use std::io::Read;
let mut src = src;
let src_len = src.len();
let dst_len = dst.len();
if dst_len >= src_len {
src.read(&mut dst[..src_len]).unwrap()
} else {
(&src[..dst_len]).read(dst).unwrap()
}
}
#[test]
fn test_copy() {
fn lr() -> (Vec<u8>, Vec<u8>) {
(b"hello".to_vec(), b"goodbye".to_vec())
}
let (mut l, r) = lr();
assert_eq!(copy(&mut l, &r), 5);
assert_eq!(l, b"goodb");
assert_eq!(r, b"goodbye");
let (l, mut r) = lr();
assert_eq!(copy(&mut r, &l[..4]), 4);
assert_eq!(l, b"hello");
assert_eq!(r, b"hellbye");
let (mut l, r) = lr();
assert_eq!(copy(&mut l[..0], &r), 0);
assert_eq!(l, b"hello");
assert_eq!(r, b"goodbye");
assert_eq!(copy(&mut l, &r[..0]), 0);
assert_eq!(l, b"hello");
assert_eq!(r, b"goodbye");
}