Skip to content

Commit

Permalink
Fix tutorial-ffi tests
Browse files Browse the repository at this point in the history
  • Loading branch information
catamorphism committed Oct 12, 2012
1 parent 5bca5f7 commit 140d16a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions doc/tutorial-ffi.md
Expand Up @@ -30,7 +30,7 @@ fn sha1(data: ~str) -> ~str unsafe {
let bytes = str::to_bytes(data);
let hash = crypto::SHA1(vec::raw::to_ptr(bytes),
vec::len(bytes) as c_uint, ptr::null());
return as_hex(vec::raw::from_buf(hash, 20));
return as_hex(vec::from_buf(hash, 20));
}
fn main(args: ~[~str]) {
Expand Down Expand Up @@ -132,7 +132,7 @@ fn sha1(data: ~str) -> ~str {
let bytes = str::to_bytes(data);
let hash = crypto::SHA1(vec::raw::to_ptr(bytes),
vec::len(bytes), ptr::null());
return as_hex(vec::raw::from_buf(hash, 20));
return as_hex(vec::from_buf(hash, 20));
}
}
~~~~
Expand Down Expand Up @@ -177,7 +177,7 @@ Let's look at our `sha1` function again.
let bytes = str::to_bytes(data);
let hash = crypto::SHA1(vec::raw::to_ptr(bytes),
vec::len(bytes), ptr::null());
return as_hex(vec::raw::from_buf(hash, 20));
return as_hex(vec::from_buf(hash, 20));
# }
# }
~~~~
Expand All @@ -198,7 +198,7 @@ unsafe null pointer of type `*u8`. (Rust generics are awesome
like that: they can take the right form depending on the type that they
are expected to return.)

Finally, `vec::raw::from_buf` builds up a new `~[u8]` from the
Finally, `vec::from_buf` builds up a new `~[u8]` from the
unsafe pointer that `SHA1` returned. SHA1 digests are always
twenty bytes long, so we can pass `20` for the length of the new
vector.
Expand Down

0 comments on commit 140d16a

Please sign in to comment.