Last active
August 29, 2015 14:00
-
-
Save jnicklas/11207246 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~/Projects/rust_stuff$ rustdoc snappy.rs --test | |
running 1 test | |
test max_compressed_length_0 ... FAILED | |
failures: | |
---- max_compressed_length_0 stdout ---- | |
<anon>:2:1: 2:19 warning: this inner attribute syntax is deprecated. The new syntax is `#![foo]`, with a bang and no semicolon. | |
<anon>:2 #[deny(warnings)]; | |
^~~~~~~~~~~~~~~~~~ | |
<anon>:3:1: 3:84 warning: this inner attribute syntax is deprecated. The new syntax is `#![foo]`, with a bang and no semicolon. | |
<anon>:3 #[allow(unused_variable, dead_assignment, unused_mut, attribute_usage, dead_code)]; | |
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
<anon>:6:1: 6:35 warning: this inner attribute syntax is deprecated. The new syntax is `#![foo]`, with a bang and no semicolon. | |
<anon>:6 #[allow(deprecated_owned_vector)]; | |
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
<anon>:8:9: 8:30 error: unresolved name `max_compressed_length`. | |
<anon>:8 let x = max_compressed_length(100); | |
^~~~~~~~~~~~~~~~~~~~~ | |
error: aborting due to previous error | |
task 'max_compressed_length_0' failed at '~Any', /private/tmp/rust-Q8uz/rust-0.10/src/libsyntax/diagnostic.rs:88 | |
failures: | |
max_compressed_length_0 | |
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured | |
task '<main>' failed at 'Some tests failed', /private/tmp/rust-Q8uz/rust-0.10/src/libtest/lib.rs:215 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![crate_id = "snappy#0.1.0"] | |
#![crate_type = "lib"] | |
use std::libc::size_t; | |
#[link(name = "snappy")] | |
extern { | |
fn snappy_max_compressed_length(source_length: size_t) -> size_t; | |
} | |
/** | |
Return the compressed length of a buffer with size x | |
``` | |
let x = max_compressed_length(100); | |
assert!(x == 148); | |
``` | |
*/ | |
pub fn max_compressed_length(x: int) -> int { | |
let length = unsafe { snappy_max_compressed_length(x as size_t) }; | |
length as int | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment