Skip to content

Commit

Permalink
[BOT] Updating fb48f8c content
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Jul 7, 2024
1 parent fb48f8c commit 7757861
Show file tree
Hide file tree
Showing 46 changed files with 773 additions and 548 deletions.
8 changes: 4 additions & 4 deletions rustbook-en/.github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ jobs:
- name: Install Rust
run: |
rustup set profile minimal
rustup toolchain install 1.78 -c rust-docs
rustup default 1.78
rustup toolchain install 1.79 -c rust-docs
rustup default 1.79
- name: Install mdbook
run: |
mkdir bin
Expand All @@ -36,8 +36,8 @@ jobs:
- name: Install Rust
run: |
rustup set profile minimal
rustup toolchain install 1.76 -c rust-docs
rustup default 1.76
rustup toolchain install 1.79 -c rust-docs
rustup default 1.79
- name: Run `tools` package tests
run: |
cargo test
Expand Down
1 change: 1 addition & 0 deletions rustbook-en/ci/dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,7 @@ Rustaceans
rUsT
rustc
rustdoc
RUSTFLAGS
Rustonomicon
rustfix
rustfmt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ error[E0308]: mismatched types
= note: expected reference `&String`
found reference `&{integer}`
note: method defined here
--> /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/cmp.rs:836:8
--> /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/cmp.rs:840:8

For more information about this error, try `rustc --explain E0308`.
error: could not compile `guessing_game` (bin "guessing_game") due to 1 previous error
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ error[E0277]: cannot add `Option<i8>` to `i8`
|
= help: the trait `Add<Option<i8>>` is not implemented for `i8`
= help: the following other types implement trait `Add<Rhs>`:
<i8 as Add>
<i8 as Add<&i8>>
<&'a i8 as Add<i8>>
<&i8 as Add<&i8>>
<i8 as Add<&i8>>
<i8 as Add>

For more information about this error, try `rustc --explain E0277`.
error: could not compile `enums` (bin "enums") due to 1 previous error
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ error[E0004]: non-exhaustive patterns: `None` not covered
| ^ pattern `None` not covered
|
note: `Option<i32>` defined here
--> /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/option.rs:572:1
::: /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/option.rs:576:5
--> /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/option.rs:571:1
::: /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/option.rs:575:5
|
= note: not covered
= note: the matched value is of type `Option<i32>`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,5 @@ help: consider introducing a named lifetime parameter
9 | fn longest<'a>(x: &'a str, y: &'a str) -> &'a str {
| ++++ ++ ++ ++

error: lifetime may not live long enough
--> src/main.rs:11:9
|
9 | fn longest(x: &str, y: &str) -> &str {
| - let's call the lifetime of this reference `'1`
10 | if x.len() > y.len() {
11 | x
| ^ returning this value requires that `'1` must outlive `'static`

error: lifetime may not live long enough
--> src/main.rs:13:9
|
9 | fn longest(x: &str, y: &str) -> &str {
| - let's call the lifetime of this reference `'2`
...
13 | y
| ^ returning this value requires that `'2` must outlive `'static`

For more information about this error, try `rustc --explain E0106`.
error: could not compile `chapter10` (bin "chapter10") due to 3 previous errors
error: could not compile `chapter10` (bin "chapter10") due to 1 previous error
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// ANCHOR: here
pub fn add(left: usize, right: usize) -> usize {
left + right
}
Expand All @@ -12,10 +11,9 @@ mod tests {
let result = add(2, 2);
assert_eq!(result, 4);
}

#[test]
fn another() {
panic!("Make this test fail");
}
}
// ANCHOR_END: here
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// ANCHOR: here
#[derive(Debug)]
struct Rectangle {
width: u32,
Expand All @@ -10,4 +9,3 @@ impl Rectangle {
self.width > other.width && self.height > other.height
}
}
// ANCHOR_END: here
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub fn add_two(a: i32) -> i32 {
pub fn add_two(a: usize) -> usize {
a + 2
}

Expand All @@ -8,6 +8,7 @@ mod tests {

#[test]
fn it_adds_two() {
assert_eq!(4, add_two(2));
let result = add_two(2);
assert_eq!(result, 4);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ failures:
I got the value 8
thread 'tests::this_test_will_fail' panicked at src/lib.rs:19:9:
assertion `left == right` failed
left: 5
right: 10
left: 10
right: 5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ mod tests {
#[test]
fn this_test_will_pass() {
let value = prints_and_returns_10(4);
assert_eq!(10, value);
assert_eq!(value, 10);
}

#[test]
fn this_test_will_fail() {
let value = prints_and_returns_10(8);
assert_eq!(5, value);
assert_eq!(value, 5);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub fn add_two(a: i32) -> i32 {
pub fn add_two(a: usize) -> usize {
a + 2
}

Expand All @@ -8,16 +8,19 @@ mod tests {

#[test]
fn add_two_and_two() {
assert_eq!(4, add_two(2));
let result = add_two(2);
assert_eq!(result, 4);
}

#[test]
fn add_three_and_two() {
assert_eq!(5, add_two(3));
let result = add_two(3);
assert_eq!(result, 5);
}

#[test]
fn one_hundred() {
assert_eq!(102, add_two(100));
let result = add_two(100);
assert_eq!(result, 102);
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
pub fn add_two(a: i32) -> i32 {
pub fn add_two(a: usize) -> usize {
internal_adder(a, 2)
}

fn internal_adder(a: i32, b: i32) -> i32 {
a + b
fn internal_adder(left: usize, right: usize) -> usize {
left + right
}

#[cfg(test)]
Expand All @@ -12,6 +12,7 @@ mod tests {

#[test]
fn internal() {
assert_eq!(4, internal_adder(2, 2));
let result = internal_adder(2, 2);
assert_eq!(result, 4);
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
pub fn add_two(a: i32) -> i32 {
pub fn add_two(a: usize) -> usize {
internal_adder(a, 2)
}

fn internal_adder(a: i32, b: i32) -> i32 {
a + b
fn internal_adder(left: usize, right: usize) -> usize {
left + right
}

#[cfg(test)]
Expand All @@ -12,6 +12,7 @@ mod tests {

#[test]
fn internal() {
assert_eq!(4, internal_adder(2, 2));
let result = internal_adder(2, 2);
assert_eq!(result, 4);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ use adder::add_two;

#[test]
fn it_adds_two() {
assert_eq!(4, add_two(2));
let result = add_two(2);
assert_eq!(result, 4);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ test tests::it_adds_two ... FAILED
failures:

---- tests::it_adds_two stdout ----
thread 'tests::it_adds_two' panicked at src/lib.rs:12:9:
assertion `left == right` failed
left: 5
right: 4
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// ANCHOR: here
pub fn add_two(a: i32) -> i32 {
pub fn add_two(a: usize) -> usize {
a + 3
}
// ANCHOR_END: here
Expand All @@ -10,6 +10,7 @@ mod tests {

#[test]
fn it_adds_two() {
assert_eq!(add_two(2), 4);
let result = add_two(2);
assert_eq!(result, 4);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ mod tests {
let result = greeting("Carol");
assert!(
result.contains("Carol"),
"Greeting did not contain name, value was `{}`",
result
"Greeting did not contain name, value was `{result}`"
);
}
// ANCHOR_END: here
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
pub fn add(left: usize, right: usize) -> usize {
left + right
}

#[cfg(test)]
mod tests {
use super::*;

// ANCHOR: here
#[test]
fn it_works() -> Result<(), String> {
if 2 + 2 == 4 {
let result = add(2, 2);

if result == 4 {
Ok(())
} else {
Err(String::from("two plus two does not equal four"))
}
}
// ANCHOR_END: here
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ $ cargo test
Running unittests src/lib.rs (target/debug/deps/adder-92948b65e88960b4)

running 2 tests
test expensive_test ... ignored
test it_works ... ok
test tests::expensive_test ... ignored
test tests::it_works ... ok

test result: ok. 1 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in 0.00s

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
pub fn add(left: usize, right: usize) -> usize {
left + right
}

#[test]
#[ignore]
fn expensive_test() {
// code that takes an hour to run
// ANCHOR: here
#[cfg(test)]
mod tests {
use super::*;

#[test]
fn it_works() {
let result = add(2, 2);
assert_eq!(result, 4);
}

#[test]
#[ignore]
fn expensive_test() {
// code that takes an hour to run
}
}
// ANCHOR_END: here
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
pub fn add_two(a: i32) -> i32 {
pub fn add_two(a: usize) -> usize {
internal_adder(a, 2)
}

fn internal_adder(a: i32, b: i32) -> i32 {
a + b
fn internal_adder(left: usize, right: usize) -> usize {
left + right
}

#[cfg(test)]
Expand All @@ -12,6 +12,7 @@ mod tests {

#[test]
fn internal() {
assert_eq!(4, internal_adder(2, 2));
let result = internal_adder(2, 2);
assert_eq!(result, 4);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use adder;
use adder::add_two;

#[test]
fn it_adds_two() {
assert_eq!(4, adder::add_two(2));
let result = add_two(2);
assert_eq!(result, 4);
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
pub fn add_two(a: i32) -> i32 {
pub fn add_two(a: usize) -> usize {
internal_adder(a, 2)
}

fn internal_adder(a: i32, b: i32) -> i32 {
a + b
fn internal_adder(left: usize, right: usize) -> usize {
left + right
}

#[cfg(test)]
Expand All @@ -12,6 +12,7 @@ mod tests {

#[test]
fn internal() {
assert_eq!(4, internal_adder(2, 2));
let result = internal_adder(2, 2);
assert_eq!(result, 4);
}
}
Loading

0 comments on commit 7757861

Please sign in to comment.