Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into french-release
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimskapt committed Jul 6, 2020
2 parents 1b4476f + 84a3139 commit ce49ab7
Show file tree
Hide file tree
Showing 110 changed files with 442 additions and 402 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: CI
on: [push, pull_request]

jobs:
test:
name: Run tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Update rustup
run: rustup self update
- name: Install Rust
run: |
rustup set profile minimal
rustup toolchain install 1.41.0 -c rust-docs
rustup default 1.41.0
- name: Install mdbook
run: |
mkdir bin
curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.3.7/mdbook-v0.3.7-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=bin
echo "##[add-path]$(pwd)/bin"
- name: Report versions
run: |
rustup --version
rustc -Vv
mdbook --version
- name: Run tests
run: mdbook test
lint:
name: Run lints
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Update rustup
run: rustup self update
- name: Install Rust
run: |
rustup set profile minimal
rustup toolchain install nightly -c rust-docs
rustup default nightly
- name: Install mdbook
run: |
mkdir bin
curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.3.7/mdbook-v0.3.7-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=bin
echo "##[add-path]$(pwd)/bin"
- name: Report versions
run: |
rustup --version
rustc -Vv
mdbook --version
- name: Spellcheck
run: bash ci/spellcheck.sh list
- name: Lint for local file paths
run: |
mdbook build
cargo run --bin lfp src
- name: Validate references
run: bash ci/validate.sh
- name: Check for broken links
run: |
curl -sSLo linkcheck.sh \
https://raw.githubusercontent.com/rust-lang/rust/master/src/tools/linkchecker/linkcheck.sh
# Cannot use --all here because of the generated redirect pages aren't available.
sh linkcheck.sh book
18 changes: 0 additions & 18 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion ADMIN_TASKS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ occasional maintenance tasks.

## Update the `rustc` version

- Change the version number in `.travis.yml`
- Change the version number in `.github/workflows/main.yml`
- Change the version number in `rust-toolchain`, which should change the version you're using
locally with `rustup`
- Change the version number in `src/title-page.md`
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ comments for any suggestions or corrections!

If you're looking for ways to help that don't involve large amounts of
reading or writing, check out the [open issues with the E-help-wanted
label][help-wanted]. These might be small fixes to the text Rust code,
label][help-wanted]. These might be small fixes to the text, Rust code,
frontend code, or shell scripts that would help us be more efficient or
enhance the book in some way!

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# The Rust Programming Language

[![Build Status](https://travis-ci.com/rust-lang/book.svg?branch=master)](https://travis-ci.com/rust-lang/book)
![Build Status](https://github.com/rust-lang/book/workflows/CI/badge.svg)

This repository contains the source of "The Rust Programming Language" book.

Expand Down
25 changes: 0 additions & 25 deletions ci/build.sh

This file was deleted.

1 change: 1 addition & 0 deletions ci/dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ chXX
chYY
clippy
clippy's
cmdlet
coercions
combinator
ConcreteType
Expand Down
4 changes: 4 additions & 0 deletions ci/validate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
for file in src/*.md ; do
echo Checking references in $file
cargo run --quiet --bin link2print < $file > /dev/null
done
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// ANCHOR: here
fn largest(list: &[i32]) -> i32 {
let mut largest = list[0];
fn largest(list: &[i32]) -> &i32 {
let mut largest = &list[0];

for &item in list {
for item in list {
if item > largest {
largest = item;
}
Expand All @@ -17,15 +17,15 @@ fn main() {
let result = largest(&number_list);
println!("The largest number is {}", result);
// ANCHOR_END: here
assert_eq!(result, 100);
assert_eq!(result, &100);
// ANCHOR: here

let number_list = vec![102, 34, 6000, 89, 54, 2, 43, 8];

let result = largest(&number_list);
println!("The largest number is {}", result);
// ANCHOR_END: here
assert_eq!(result, 6000);
assert_eq!(result, &6000);
// ANCHOR: here
}
// ANCHOR_END: here
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// ANCHOR: here
fn largest_i32(list: &[i32]) -> i32 {
let mut largest = list[0];
fn largest_i32(list: &[i32]) -> &i32 {
let mut largest = &list[0];

for &item in list {
for item in list {
if item > largest {
largest = item;
}
Expand All @@ -11,10 +11,10 @@ fn largest_i32(list: &[i32]) -> i32 {
largest
}

fn largest_char(list: &[char]) -> char {
let mut largest = list[0];
fn largest_char(list: &[char]) -> &char {
let mut largest = &list[0];

for &item in list {
for item in list {
if item > largest {
largest = item;
}
Expand All @@ -29,15 +29,15 @@ fn main() {
let result = largest_i32(&number_list);
println!("The largest number is {}", result);
// ANCHOR_END: here
assert_eq!(result, 100);
assert_eq!(result, &100);
// ANCHOR: here

let char_list = vec!['y', 'm', 'a', 'q'];

let result = largest_char(&char_list);
println!("The largest char is {}", result);
// ANCHOR_END: here
assert_eq!(result, 'y');
assert_eq!(result, &'y');
// ANCHOR: here
}
// ANCHOR_END: here
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
fn largest<T>(list: &[T]) -> T {
fn largest<T>(list: &[T]) -> &T {
let mut largest = list[0];

for &item in list {
for item in list {
if item > largest {
largest = item;
}
Expand Down
2 changes: 1 addition & 1 deletion listings/ch13-functional-features/listing-13-26/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub struct Config {

// ANCHOR: here
impl Config {
pub fn new(mut args: std::env::Args) -> Result<Config, &'static str> {
pub fn new(mut args: env::Args) -> Result<Config, &'static str> {
// --snip--
// ANCHOR_END: here
if args.len() < 3 {
Expand Down
2 changes: 1 addition & 1 deletion listings/ch13-functional-features/listing-13-27/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub struct Config {

// ANCHOR: here
impl Config {
pub fn new(mut args: std::env::Args) -> Result<Config, &'static str> {
pub fn new(mut args: env::Args) -> Result<Config, &'static str> {
args.next();

let query = match args.next() {
Expand Down
4 changes: 2 additions & 2 deletions listings/ch15-smart-pointers/listing-15-24/output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ $ cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.63s
Running `target/debug/cons-list`
a after = Cons(RefCell { value: 15 }, Nil)
b after = Cons(RefCell { value: 6 }, Cons(RefCell { value: 15 }, Nil))
c after = Cons(RefCell { value: 10 }, Cons(RefCell { value: 15 }, Nil))
b after = Cons(RefCell { value: 3 }, Cons(RefCell { value: 15 }, Nil))
c after = Cons(RefCell { value: 4 }, Cons(RefCell { value: 15 }, Nil))
4 changes: 2 additions & 2 deletions listings/ch15-smart-pointers/listing-15-24/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ fn main() {

let a = Rc::new(Cons(Rc::clone(&value), Rc::new(Nil)));

let b = Cons(Rc::new(RefCell::new(6)), Rc::clone(&a));
let c = Cons(Rc::new(RefCell::new(10)), Rc::clone(&a));
let b = Cons(Rc::new(RefCell::new(3)), Rc::clone(&a));
let c = Cons(Rc::new(RefCell::new(4)), Rc::clone(&a));

*value.borrow_mut() += 10;

Expand Down
2 changes: 1 addition & 1 deletion listings/ch20-web-server/listing-20-02/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fn main() {
}

fn handle_connection(mut stream: TcpStream) {
let mut buffer = [0; 512];
let mut buffer = [0; 1024];

stream.read(&mut buffer).unwrap();

Expand Down
2 changes: 1 addition & 1 deletion listings/ch20-web-server/listing-20-03/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fn main() {

// ANCHOR: here
fn handle_connection(mut stream: TcpStream) {
let mut buffer = [0; 512];
let mut buffer = [0; 1024];

stream.read(&mut buffer).unwrap();

Expand Down
2 changes: 1 addition & 1 deletion listings/ch20-web-server/listing-20-04/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fn main() {
}

fn handle_connection(mut stream: TcpStream) {
let mut buffer = [0; 512];
let mut buffer = [0; 1024];

stream.read(&mut buffer).unwrap();

Expand Down
8 changes: 6 additions & 2 deletions listings/ch20-web-server/listing-20-05/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,16 @@ fn main() {

// ANCHOR: here
fn handle_connection(mut stream: TcpStream) {
let mut buffer = [0; 512];
let mut buffer = [0; 1024];
stream.read(&mut buffer).unwrap();

let contents = fs::read_to_string("hello.html").unwrap();

let response = format!("HTTP/1.1 200 OK\r\n\r\n{}", contents);
let response = format!(
"HTTP/1.1 200 OK\r\nContent-Length: {}\r\n\r\n{}",
contents.len(),
contents
);

stream.write(response.as_bytes()).unwrap();
stream.flush().unwrap();
Expand Down
8 changes: 6 additions & 2 deletions listings/ch20-web-server/listing-20-06/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,19 @@ fn main() {
// --snip--

fn handle_connection(mut stream: TcpStream) {
let mut buffer = [0; 512];
let mut buffer = [0; 1024];
stream.read(&mut buffer).unwrap();

let get = b"GET / HTTP/1.1\r\n";

if buffer.starts_with(get) {
let contents = fs::read_to_string("hello.html").unwrap();

let response = format!("HTTP/1.1 200 OK\r\n\r\n{}", contents);
let response = format!(
"HTTP/1.1 200 OK\r\nContent-Length: {}\r\n\r\n{}",
contents.len(),
contents
);

stream.write(response.as_bytes()).unwrap();
stream.flush().unwrap();
Expand Down
8 changes: 6 additions & 2 deletions listings/ch20-web-server/listing-20-07/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,19 @@ fn main() {
}

fn handle_connection(mut stream: TcpStream) {
let mut buffer = [0; 512];
let mut buffer = [0; 1024];
stream.read(&mut buffer).unwrap();

let get = b"GET / HTTP/1.1\r\n";

if buffer.starts_with(get) {
let contents = fs::read_to_string("hello.html").unwrap();

let response = format!("HTTP/1.1 200 OK\r\n\r\n{}", contents);
let response = format!(
"HTTP/1.1 200 OK\r\nContent-Length: {}\r\n\r\n{}",
contents.len(),
contents
);

stream.write(response.as_bytes()).unwrap();
stream.flush().unwrap();
Expand Down
8 changes: 6 additions & 2 deletions listings/ch20-web-server/listing-20-08/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,19 @@ fn main() {
}

fn handle_connection(mut stream: TcpStream) {
let mut buffer = [0; 512];
let mut buffer = [0; 1024];
stream.read(&mut buffer).unwrap();

let get = b"GET / HTTP/1.1\r\n";

if buffer.starts_with(get) {
let contents = fs::read_to_string("hello.html").unwrap();

let response = format!("HTTP/1.1 200 OK\r\n\r\n{}", contents);
let response = format!(
"HTTP/1.1 200 OK\r\nContent-Length: {}\r\n\r\n{}",
contents.len(),
contents
);

stream.write(response.as_bytes()).unwrap();
stream.flush().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion listings/ch20-web-server/listing-20-09/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ fn handle_connection(mut stream: TcpStream) {
// --snip--

// ANCHOR_END: here
let mut buffer = [0; 512];
let mut buffer = [0; 1024];
stream.read(&mut buffer).unwrap();

let get = b"GET / HTTP/1.1\r\n";
Expand Down
Loading

0 comments on commit ce49ab7

Please sign in to comment.