mirror of
https://github.com/tokio-rs/bytes.git
synced 2026-08-18 00:00:12 +02:00
Track Rust master
This commit is contained in:
+1
-1
@@ -19,7 +19,7 @@ exclude = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
rand = "0.1.2"
|
rand = "0.2.1"
|
||||||
|
|
||||||
[[bench]]
|
[[bench]]
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -61,7 +61,7 @@ pub trait Buf {
|
|||||||
/// let mut dst = [0; 5];
|
/// let mut dst = [0; 5];
|
||||||
///
|
///
|
||||||
/// buf.read_slice(&mut dst);
|
/// buf.read_slice(&mut dst);
|
||||||
/// assert_eq!(b"hello", dst);
|
/// assert_eq!(b"hello", &dst);
|
||||||
/// assert_eq!(6, buf.remaining());
|
/// assert_eq!(6, buf.remaining());
|
||||||
/// ```
|
/// ```
|
||||||
fn read_slice(&mut self, dst: &mut [u8]) -> usize {
|
fn read_slice(&mut self, dst: &mut [u8]) -> usize {
|
||||||
@@ -144,7 +144,7 @@ pub trait MutBuf : Sized {
|
|||||||
/// assert_eq!(1, buf.remaining());
|
/// assert_eq!(1, buf.remaining());
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// assert_eq!(b"hello\0", dst);
|
/// assert_eq!(b"hello\0", &dst);
|
||||||
/// ```
|
/// ```
|
||||||
fn write_slice(&mut self, src: &[u8]) -> usize {
|
fn write_slice(&mut self, src: &[u8]) -> usize {
|
||||||
let mut off = 0;
|
let mut off = 0;
|
||||||
|
|||||||
@@ -21,26 +21,26 @@ pub fn test_initial_buf_empty() {
|
|||||||
pub fn test_byte_buf_read_write() {
|
pub fn test_byte_buf_read_write() {
|
||||||
let mut buf = ByteBuf::mut_with_capacity(32);
|
let mut buf = ByteBuf::mut_with_capacity(32);
|
||||||
|
|
||||||
buf.write(b"hello world").unwrap();
|
buf.write(b"hello world".as_slice()).unwrap();
|
||||||
assert_eq!(21, buf.remaining());
|
assert_eq!(21, buf.remaining());
|
||||||
|
|
||||||
buf.write(b" goodbye").unwrap();
|
buf.write(b" goodbye".as_slice()).unwrap();
|
||||||
assert_eq!(13, buf.remaining());
|
assert_eq!(13, buf.remaining());
|
||||||
|
|
||||||
let mut buf = buf.flip();
|
let mut buf = buf.flip();
|
||||||
let mut dst = [0; 5];
|
let mut dst = [0; 5];
|
||||||
|
|
||||||
assert_eq!(5, buf.read(dst.as_mut_slice()).unwrap());
|
assert_eq!(5, buf.read(dst.as_mut_slice()).unwrap());
|
||||||
assert_eq!(b"hello", dst);
|
assert_eq!(b"hello", &dst);
|
||||||
|
|
||||||
assert_eq!(5, buf.read(dst.as_mut_slice()).unwrap());
|
assert_eq!(5, buf.read(dst.as_mut_slice()).unwrap());
|
||||||
assert_eq!(b" worl", dst);
|
assert_eq!(b" worl", &dst);
|
||||||
|
|
||||||
let mut dst = [0; 2];
|
let mut dst = [0; 2];
|
||||||
assert_eq!(2, buf.read(dst.as_mut_slice()).unwrap());
|
assert_eq!(2, buf.read(dst.as_mut_slice()).unwrap());
|
||||||
assert_eq!(b"d ", dst);
|
assert_eq!(b"d ", &dst);
|
||||||
|
|
||||||
let mut dst = [0; 7];
|
let mut dst = [0; 7];
|
||||||
assert_eq!(7, buf.read(dst.as_mut_slice()).unwrap());
|
assert_eq!(7, buf.read(dst.as_mut_slice()).unwrap());
|
||||||
assert_eq!(b"goodbye", dst);
|
assert_eq!(b"goodbye", &dst);
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-21
@@ -3,29 +3,29 @@ use bytes::traits::*;
|
|||||||
use super::gen_bytes;
|
use super::gen_bytes;
|
||||||
|
|
||||||
const TEST_BYTES_1: &'static [u8] =
|
const TEST_BYTES_1: &'static [u8] =
|
||||||
&b"dblm4ng7jp4v9rdn1w6hhssmluoqrrrqj59rccl9
|
b"dblm4ng7jp4v9rdn1w6hhssmluoqrrrqj59rccl9
|
||||||
nkv2tm1t2da4jyku51ge7f8hv581gkki8lekmf5f
|
nkv2tm1t2da4jyku51ge7f8hv581gkki8lekmf5f
|
||||||
1l44whp4aiwbvhkziw02292on4noyvuwjzsloqyc
|
1l44whp4aiwbvhkziw02292on4noyvuwjzsloqyc
|
||||||
5n0iyn4l6o6tgjhlek00mynfzb1wgcwj4mqp6zdr
|
5n0iyn4l6o6tgjhlek00mynfzb1wgcwj4mqp6zdr
|
||||||
3625yy7rj7xuisal7b1a7xgq271abvt5ssxuj39v
|
3625yy7rj7xuisal7b1a7xgq271abvt5ssxuj39v
|
||||||
njtetokxxrgxzp7ik9adnypkmmcn4270yv9l46m7
|
njtetokxxrgxzp7ik9adnypkmmcn4270yv9l46m7
|
||||||
9mu2zmqmkxdmgia210vkdytb7ywfcyt2bvcsg9eq
|
9mu2zmqmkxdmgia210vkdytb7ywfcyt2bvcsg9eq
|
||||||
5yqizxl6888zrksvaxhzs2v355jxu8gr21m33t83
|
5yqizxl6888zrksvaxhzs2v355jxu8gr21m33t83
|
||||||
qvoian1ra7c6pvxabshgngldxa408p18l1fdet2h";
|
qvoian1ra7c6pvxabshgngldxa408p18l1fdet2h";
|
||||||
|
|
||||||
const TEST_BYTES_2: &'static [u8] =
|
const TEST_BYTES_2: &'static [u8] =
|
||||||
&b"jmh14t79mllzj1ohxfj6fun7idwbks8oh35f83g6
|
b"jmh14t79mllzj1ohxfj6fun7idwbks8oh35f83g6
|
||||||
ryaowe86mmou5t1xa91uyg8e95wcu5mje1mswien
|
ryaowe86mmou5t1xa91uyg8e95wcu5mje1mswien
|
||||||
tt4clgj029cw0pyuvfbvsgzdg1x7sr9qsjkf2b1t
|
tt4clgj029cw0pyuvfbvsgzdg1x7sr9qsjkf2b1t
|
||||||
h43smgp1ea22lph17f78cel0cc2kjoht5281xuy8
|
h43smgp1ea22lph17f78cel0cc2kjoht5281xuy8
|
||||||
0ex9uaqwj4330jrp30stsk15j9bpqezu3w78ktit
|
0ex9uaqwj4330jrp30stsk15j9bpqezu3w78ktit
|
||||||
ev5g6xsngr35q7pemdm9hihf0ebrw5fbwhm530lo
|
ev5g6xsngr35q7pemdm9hihf0ebrw5fbwhm530lo
|
||||||
e0zyj1bm7yfyk7f2i45jhr3wu3bvb4hj8jve6db0
|
e0zyj1bm7yfyk7f2i45jhr3wu3bvb4hj8jve6db0
|
||||||
iewmr9weecaon9vdnqo5hen9iaiox5vsaxuo461m
|
iewmr9weecaon9vdnqo5hen9iaiox5vsaxuo461m
|
||||||
8336ugp20u4sfky3kfawr0ome1tiqyx8chkerrjh
|
8336ugp20u4sfky3kfawr0ome1tiqyx8chkerrjh
|
||||||
a95s0gypcsgo9jqxasqkoj08t4uq5moxmay5plg5
|
a95s0gypcsgo9jqxasqkoj08t4uq5moxmay5plg5
|
||||||
tlh6f9omhn0ezvi0w2n8hx7n6qk7rn1s3mjpnpl6
|
tlh6f9omhn0ezvi0w2n8hx7n6qk7rn1s3mjpnpl6
|
||||||
hvilp8awaa4tvsis66q4e5b3xwy2z1h2klpa87h7";
|
hvilp8awaa4tvsis66q4e5b3xwy2z1h2klpa87h7";
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
pub fn test_rope_round_trip() {
|
pub fn test_rope_round_trip() {
|
||||||
|
|||||||
Reference in New Issue
Block a user