Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
bytes-sgx
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Markus Becker
bytes-sgx
Commits
a87dea0b
Commit
a87dea0b
authored
10 years ago
by
Carl Lerche
Browse files
Options
Downloads
Patches
Plain Diff
Track Rust master
parent
3f9b7f6d
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
Cargo.toml
+1
-1
1 addition, 1 deletion
Cargo.toml
src/lib.rs
+2
-2
2 additions, 2 deletions
src/lib.rs
test/test_byte_buf.rs
+6
-6
6 additions, 6 deletions
test/test_byte_buf.rs
test/test_rope.rs
+21
-21
21 additions, 21 deletions
test/test_rope.rs
with
30 additions
and
30 deletions
Cargo.toml
+
1
−
1
View file @
a87dea0b
...
...
@@ -19,7 +19,7 @@ exclude = [
]
[dev-dependencies]
rand
=
"0.
1.2
"
rand
=
"0.
2.1
"
[[bench]]
...
...
This diff is collapsed.
Click to expand it.
src/lib.rs
+
2
−
2
View file @
a87dea0b
...
...
@@ -61,7 +61,7 @@ pub trait Buf {
/// let mut dst = [0; 5];
///
/// buf.read_slice(&mut dst);
/// assert_eq!(b"hello", dst);
/// assert_eq!(b"hello",
&
dst);
/// assert_eq!(6, buf.remaining());
/// ```
fn
read_slice
(
&
mut
self
,
dst
:
&
mut
[
u8
])
->
usize
{
...
...
@@ -144,7 +144,7 @@ pub trait MutBuf : Sized {
/// 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
{
let
mut
off
=
0
;
...
...
This diff is collapsed.
Click to expand it.
test/test_byte_buf.rs
+
6
−
6
View file @
a87dea0b
...
...
@@ -21,26 +21,26 @@ pub fn test_initial_buf_empty() {
pub
fn
test_byte_buf_read_write
()
{
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
());
buf
.write
(
b" goodbye"
)
.unwrap
();
buf
.write
(
b" goodbye"
.as_slice
()
)
.unwrap
();
assert_eq!
(
13
,
buf
.remaining
());
let
mut
buf
=
buf
.flip
();
let
mut
dst
=
[
0
;
5
];
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!
(
b" worl"
,
dst
);
assert_eq!
(
b" worl"
,
&
dst
);
let
mut
dst
=
[
0
;
2
];
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
];
assert_eq!
(
7
,
buf
.read
(
dst
.as_mut_slice
())
.unwrap
());
assert_eq!
(
b"goodbye"
,
dst
);
assert_eq!
(
b"goodbye"
,
&
dst
);
}
This diff is collapsed.
Click to expand it.
test/test_rope.rs
+
21
−
21
View file @
a87dea0b
...
...
@@ -3,29 +3,29 @@ use bytes::traits::*;
use
super
::
gen_bytes
;
const
TEST_BYTES_1
:
&
'static
[
u8
]
=
&
b"dblm4ng7jp4v9rdn1w6hhssmluoqrrrqj59rccl9
nkv2tm1t2da4jyku51ge7f8hv581gkki8lekmf5f
1l44whp4aiwbvhkziw02292on4noyvuwjzsloqyc
5n0iyn4l6o6tgjhlek00mynfzb1wgcwj4mqp6zdr
3625yy7rj7xuisal7b1a7xgq271abvt5ssxuj39v
njtetokxxrgxzp7ik9adnypkmmcn4270yv9l46m7
9mu2zmqmkxdmgia210vkdytb7ywfcyt2bvcsg9eq
5yqizxl6888zrksvaxhzs2v355jxu8gr21m33t83
qvoian1ra7c6pvxabshgngldxa408p18l1fdet2h"
;
b"dblm4ng7jp4v9rdn1w6hhssmluoqrrrqj59rccl9
nkv2tm1t2da4jyku51ge7f8hv581gkki8lekmf5f
1l44whp4aiwbvhkziw02292on4noyvuwjzsloqyc
5n0iyn4l6o6tgjhlek00mynfzb1wgcwj4mqp6zdr
3625yy7rj7xuisal7b1a7xgq271abvt5ssxuj39v
njtetokxxrgxzp7ik9adnypkmmcn4270yv9l46m7
9mu2zmqmkxdmgia210vkdytb7ywfcyt2bvcsg9eq
5yqizxl6888zrksvaxhzs2v355jxu8gr21m33t83
qvoian1ra7c6pvxabshgngldxa408p18l1fdet2h"
;
const
TEST_BYTES_2
:
&
'static
[
u8
]
=
&
b"jmh14t79mllzj1ohxfj6fun7idwbks8oh35f83g6
ryaowe86mmou5t1xa91uyg8e95wcu5mje1mswien
tt4clgj029cw0pyuvfbvsgzdg1x7sr9qsjkf2b1t
h43smgp1ea22lph17f78cel0cc2kjoht5281xuy8
0ex9uaqwj4330jrp30stsk15j9bpqezu3w78ktit
ev5g6xsngr35q7pemdm9hihf0ebrw5fbwhm530lo
e0zyj1bm7yfyk7f2i45jhr3wu3bvb4hj8jve6db0
iewmr9weecaon9vdnqo5hen9iaiox5vsaxuo461m
8336ugp20u4sfky3kfawr0ome1tiqyx8chkerrjh
a95s0gypcsgo9jqxasqkoj08t4uq5moxmay5plg5
tlh6f9omhn0ezvi0w2n8hx7n6qk7rn1s3mjpnpl6
hvilp8awaa4tvsis66q4e5b3xwy2z1h2klpa87h7"
;
b"jmh14t79mllzj1ohxfj6fun7idwbks8oh35f83g6
ryaowe86mmou5t1xa91uyg8e95wcu5mje1mswien
tt4clgj029cw0pyuvfbvsgzdg1x7sr9qsjkf2b1t
h43smgp1ea22lph17f78cel0cc2kjoht5281xuy8
0ex9uaqwj4330jrp30stsk15j9bpqezu3w78ktit
ev5g6xsngr35q7pemdm9hihf0ebrw5fbwhm530lo
e0zyj1bm7yfyk7f2i45jhr3wu3bvb4hj8jve6db0
iewmr9weecaon9vdnqo5hen9iaiox5vsaxuo461m
8336ugp20u4sfky3kfawr0ome1tiqyx8chkerrjh
a95s0gypcsgo9jqxasqkoj08t4uq5moxmay5plg5
tlh6f9omhn0ezvi0w2n8hx7n6qk7rn1s3mjpnpl6
hvilp8awaa4tvsis66q4e5b3xwy2z1h2klpa87h7"
;
#[test]
pub
fn
test_rope_round_trip
()
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment