Merge branch 'master' into revert-trivial-wording

pull/498/head
Arhan Chaudhary 4 weeks ago committed by GitHub
commit d1c6b95dcb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1,5 +1,5 @@
[book] [book]
author = "The Rust Project Developers" authors = ["The Rust Project Developers"]
title = "The Rustonomicon" title = "The Rustonomicon"
description = "The Dark Arts of Advanced and Unsafe Rust Programming" description = "The Dark Arts of Advanced and Unsafe Rust Programming"

@ -104,7 +104,7 @@ code and the unsafe code into two separate phases:
```text ```text
bubble_up(heap, index): bubble_up(heap, index):
let end_index = index; let end_index = index;
while end_index != 0 && heap[end_index] < heap[parent(end_index)]: while end_index != 0 && heap[index] < heap[parent(end_index)]:
end_index = parent(end_index) end_index = parent(end_index)
let elem = heap[index] let elem = heap[index]

@ -25,7 +25,7 @@ libc = "0.2.0"
Because [snappy](https://github.com/google/snappy) is a static library by default. Because [snappy](https://github.com/google/snappy) is a static library by default.
So there is no C++ std linked in the output artifact. So there is no C++ std linked in the output artifact.
n order to use this foreign library in Rust, we have to manually specify that we want to link stdc++ in our project. In order to use this foreign library in Rust, we have to manually specify that we want to link stdc++ in our project.
The easiest way to do this is by setting up a build script. The easiest way to do this is by setting up a build script.
First edit `Cargo.toml`, inside `package` add `build = "build.rs"`: First edit `Cargo.toml`, inside `package` add `build = "build.rs"`:
@ -90,7 +90,7 @@ The `extern` block can be extended to cover the entire snappy API:
use libc::{c_int, size_t}; use libc::{c_int, size_t};
#[link(name = "snappy")] #[link(name = "snappy")]
unsafe extern { unsafe extern "C" {
fn snappy_compress(input: *const u8, fn snappy_compress(input: *const u8,
input_length: size_t, input_length: size_t,
compressed: *mut u8, compressed: *mut u8,

Loading…
Cancel
Save