├── first-edition ├── src │ ├── chapter_1.md │ ├── effective-rust.md │ └── syntax-and-semantics.md └── book.toml ├── second-edition ├── examples │ ├── ch10 │ │ ├── ch9 │ │ │ ├── ch9_4 │ │ │ │ ├── hello.txt │ │ │ │ └── Cargo.toml │ │ │ ├── ch9_3 │ │ │ │ ├── hello.txt │ │ │ │ ├── Cargo.toml │ │ │ │ └── src │ │ │ │ │ └── main.rs │ │ │ ├── ch9_8 │ │ │ │ ├── hello.txt │ │ │ │ ├── Cargo.toml │ │ │ │ └── src │ │ │ │ │ └── main.rs │ │ │ ├── ch9_1 │ │ │ │ ├── src │ │ │ │ │ └── main.rs │ │ │ │ └── Cargo.toml │ │ │ ├── pr9_panic1 │ │ │ │ ├── src │ │ │ │ │ └── main.rs │ │ │ │ └── Cargo.toml │ │ │ ├── ch9_10 │ │ │ │ ├── src │ │ │ │ │ └── main.rs │ │ │ │ └── Cargo.toml │ │ │ ├── ch9_5 │ │ │ │ ├── src │ │ │ │ │ └── main.rs │ │ │ │ └── Cargo.toml │ │ │ ├── ch9_2 │ │ │ │ ├── Cargo.toml │ │ │ │ └── src │ │ │ │ │ └── main.rs │ │ │ ├── ch9_6 │ │ │ │ ├── Cargo.toml │ │ │ │ └── src │ │ │ │ │ └── main.rs │ │ │ ├── ch9_7 │ │ │ │ └── Cargo.toml │ │ │ ├── ch9_9 │ │ │ │ ├── Cargo.toml │ │ │ │ └── src │ │ │ │ │ └── main.rs │ │ │ ├── ch9_11 │ │ │ │ ├── Cargo.toml │ │ │ │ └── src │ │ │ │ │ └── main.rs │ │ │ └── ch9_12 │ │ │ │ └── Cargo.toml │ │ ├── ch10_27_1 │ │ │ ├── src │ │ │ │ └── main.rs │ │ │ └── Cargo.toml │ │ ├── ch10_1 │ │ │ └── Cargo.toml │ │ ├── ch10_18 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch10_2 │ │ │ └── Cargo.toml │ │ ├── ch10_20 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch10_21 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch10_22 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch10_23 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch10_24 │ │ │ └── Cargo.toml │ │ ├── ch10_25 │ │ │ └── Cargo.toml │ │ ├── ch10_26 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch10_27 │ │ │ └── Cargo.toml │ │ ├── ch10_3 │ │ │ └── Cargo.toml │ │ ├── ch10_4 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch10_5 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch10_6 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch10_7 │ │ │ └── Cargo.toml │ │ ├── ch10_8 │ │ │ └── Cargo.toml │ │ ├── ch10_25_1 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch10_25_2 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch10_27_2 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ └── ch10_weather_forecast │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ └── main.rs │ ├── ch3 │ │ ├── ch3_19 │ │ │ ├── src │ │ │ │ └── main.rs │ │ │ └── Cargo.toml │ │ ├── ch3_5 │ │ │ ├── src │ │ │ │ └── main.rs │ │ │ └── Cargo.toml │ │ ├── ch3_7 │ │ │ ├── src │ │ │ │ └── main.rs │ │ │ └── Cargo.toml │ │ ├── ch3_1 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch3_2 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch3_29 │ │ │ ├── src │ │ │ │ └── main.rs │ │ │ └── Cargo.toml │ │ ├── ch3_3 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch3_4 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch3_6 │ │ │ └── Cargo.toml │ │ ├── ch3_8 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch3_9 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch3_10 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch3_11 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch3_12 │ │ │ └── Cargo.toml │ │ ├── ch3_13 │ │ │ └── Cargo.toml │ │ ├── ch3_14 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch3_15 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch3_16 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch3_17 │ │ │ └── Cargo.toml │ │ ├── ch3_18 │ │ │ └── Cargo.toml │ │ ├── ch3_20 │ │ │ └── Cargo.toml │ │ ├── ch3_21 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch3_22 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch3_23 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch3_24 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch3_25 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch3_26 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch3_27 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch3_28 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch3_30 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch3_31 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch3_32 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch3_33 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ └── ch3_34 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ └── main.rs │ ├── ch4 │ │ ├── ch4_13 │ │ │ ├── src │ │ │ │ └── main.rs │ │ │ └── Cargo.toml │ │ ├── ch4_1 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch4_2 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch4_3 │ │ │ └── Cargo.toml │ │ ├── ch4_4 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch4_5 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch4_6 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch4_7 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch4_8 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch4_9 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch4_10 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch4_11 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch4_12 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch4_14 │ │ │ └── Cargo.toml │ │ ├── ch4_15 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch4_16 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch4_17 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ └── ch4_18 │ │ │ └── Cargo.toml │ ├── ch7 │ │ ├── communicator │ │ │ ├── src │ │ │ │ ├── client.rs │ │ │ │ ├── network │ │ │ │ │ ├── server.rs │ │ │ │ │ └── mod.rs │ │ │ │ ├── main.rs │ │ │ │ └── lib.rs │ │ │ └── Cargo.toml │ │ ├── secret │ │ │ ├── src │ │ │ │ └── lib.rs │ │ │ └── Cargo.toml │ │ ├── ch7_1 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch7_2 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch7_3 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch7_4 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch7_5 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ └── ch7_6 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ └── main.rs │ ├── ch12 │ │ ├── minigrep12 │ │ │ ├── output.txt │ │ │ ├── Cargo.toml │ │ │ └── poem.txt │ │ ├── minigrep13 │ │ │ ├── output.txt │ │ │ ├── Cargo.toml │ │ │ └── poem.txt │ │ ├── minigrep │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── minigrep1 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── minigrep10 │ │ │ ├── Cargo.toml │ │ │ └── poem.txt │ │ ├── minigrep11 │ │ │ ├── Cargo.toml │ │ │ └── poem.txt │ │ ├── minigrep2 │ │ │ ├── Cargo.toml │ │ │ └── poem.txt │ │ ├── minigrep3 │ │ │ ├── Cargo.toml │ │ │ └── poem.txt │ │ ├── minigrep4 │ │ │ ├── Cargo.toml │ │ │ └── poem.txt │ │ ├── minigrep5 │ │ │ ├── Cargo.toml │ │ │ └── poem.txt │ │ ├── minigrep6 │ │ │ ├── Cargo.toml │ │ │ └── poem.txt │ │ ├── minigrep7 │ │ │ ├── Cargo.toml │ │ │ └── poem.txt │ │ ├── minigrep8 │ │ │ ├── Cargo.toml │ │ │ └── poem.txt │ │ └── minigrep9 │ │ │ ├── Cargo.toml │ │ │ └── poem.txt │ ├── ch13 │ │ ├── minigrep13_1 │ │ │ ├── output.txt │ │ │ ├── Cargo.toml │ │ │ └── poem.txt │ │ ├── ch13_5 │ │ │ ├── src │ │ │ │ └── main.rs │ │ │ └── Cargo.toml │ │ ├── ch13_1 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ ├── main.rs │ │ │ │ └── lib.rs │ │ ├── ch13_2 │ │ │ └── Cargo.toml │ │ ├── ch13_3 │ │ │ └── Cargo.toml │ │ ├── ch13_4 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch13_6 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch13_7 │ │ │ └── Cargo.toml │ │ └── ch13_8 │ │ │ └── Cargo.toml │ ├── ch19 │ │ ├── ch19_15 │ │ │ ├── src │ │ │ │ └── main.rs │ │ │ └── Cargo.toml │ │ ├── ch19_16 │ │ │ ├── src │ │ │ │ └── main.rs │ │ │ └── Cargo.toml │ │ ├── ch19_17 │ │ │ ├── src │ │ │ │ └── main.rs │ │ │ └── Cargo.toml │ │ ├── ch19_33 │ │ │ ├── src │ │ │ │ └── main.rs │ │ │ └── Cargo.toml │ │ ├── ch19_34 │ │ │ ├── src │ │ │ │ └── main.rs │ │ │ └── Cargo.toml │ │ ├── ch19_7 │ │ │ ├── src │ │ │ │ └── main.rs │ │ │ └── Cargo.toml │ │ ├── ch19_19 │ │ │ ├── src │ │ │ │ └── main.rs │ │ │ └── Cargo.toml │ │ ├── ch19_1 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch19_10 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch19_11 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch19_12 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch19_13 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch19_14 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch19_18 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch19_2 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch19_20 │ │ │ └── Cargo.toml │ │ ├── ch19_21 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch19_22 │ │ │ └── Cargo.toml │ │ ├── ch19_23 │ │ │ └── Cargo.toml │ │ ├── ch19_24 │ │ │ └── Cargo.toml │ │ ├── ch19_25 │ │ │ └── Cargo.toml │ │ ├── ch19_26 │ │ │ └── Cargo.toml │ │ ├── ch19_27 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch19_28 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch19_29 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch19_3 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch19_30 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch19_31 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch19_32 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch19_4 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch19_5 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch19_6 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch19_8 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ └── ch19_9 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ └── main.rs │ ├── ch8 │ │ ├── ch8_2 │ │ │ ├── src │ │ │ │ └── main.rs │ │ │ └── Cargo.toml │ │ ├── ch8_1 │ │ │ ├── src │ │ │ │ └── main.rs │ │ │ └── Cargo.toml │ │ ├── ch8_3 │ │ │ ├── src │ │ │ │ └── main.rs │ │ │ └── Cargo.toml │ │ ├── ch8_6 │ │ │ ├── src │ │ │ │ └── main.rs │ │ │ └── Cargo.toml │ │ ├── ch8_15_1 │ │ │ ├── src │ │ │ │ └── main.rs │ │ │ └── Cargo.toml │ │ ├── ch8_16 │ │ │ ├── src │ │ │ │ └── main.rs │ │ │ └── Cargo.toml │ │ ├── ch8_17 │ │ │ ├── src │ │ │ │ └── main.rs │ │ │ └── Cargo.toml │ │ ├── ch8_15_2 │ │ │ ├── src │ │ │ │ └── main.rs │ │ │ └── Cargo.toml │ │ ├── ch8_14 │ │ │ ├── src │ │ │ │ └── main.rs │ │ │ └── Cargo.toml │ │ ├── ch8_10 │ │ │ ├── src │ │ │ │ └── main.rs │ │ │ └── Cargo.toml │ │ ├── ch8_4 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch8_5 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch8_7 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch8_8 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch8_9 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch8_11 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch8_12 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch8_13 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch8_18 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch8_19 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch8_20 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch8_21 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch8_22 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch8_23 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch8_24 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ └── ch8_25 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ └── main.rs │ ├── ch15 │ │ ├── ch15_1 │ │ │ ├── src │ │ │ │ └── main.rs │ │ │ └── Cargo.toml │ │ ├── ch15_10 │ │ │ ├── src │ │ │ │ └── main.rs │ │ │ └── Cargo.toml │ │ ├── ch15_6 │ │ │ ├── src │ │ │ │ ├── lib.rs │ │ │ │ └── main.rs │ │ │ └── Cargo.toml │ │ ├── ch15_6_1 │ │ │ ├── src │ │ │ │ ├── lib.rs │ │ │ │ └── main.rs │ │ │ └── Cargo.toml │ │ ├── ch15_11 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch15_12 │ │ │ └── Cargo.toml │ │ ├── ch15_2 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch15_3 │ │ │ └── Cargo.toml │ │ ├── ch15_4 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch15_5 │ │ │ └── Cargo.toml │ │ ├── ch15_7 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch15_8 │ │ │ └── Cargo.toml │ │ ├── ch15_9 │ │ │ └── Cargo.toml │ │ └── ch15_6_2 │ │ │ └── Cargo.toml │ ├── ch18 │ │ ├── ch18_18 │ │ │ ├── src │ │ │ │ └── main.rs │ │ │ └── Cargo.toml │ │ ├── ch18_5 │ │ │ ├── src │ │ │ │ └── main.rs │ │ │ └── Cargo.toml │ │ ├── ch18_15 │ │ │ ├── src │ │ │ │ └── main.rs │ │ │ └── Cargo.toml │ │ ├── ch18_1 │ │ │ └── Cargo.toml │ │ ├── ch18_10 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch18_11 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch18_12 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch18_13 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch18_14 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch18_16 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch18_17 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch18_19 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch18_2 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch18_20 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch18_21 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch18_22 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch18_23 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch18_24 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch18_25 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch18_26 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch18_27 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch18_28 │ │ │ └── Cargo.toml │ │ ├── ch18_3 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch18_4 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch18_6 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch18_7 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch18_8 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ └── ch18_9 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ └── main.rs │ ├── ch11 │ │ ├── adder │ │ │ ├── tests │ │ │ │ ├── common │ │ │ │ │ └── mod.rs │ │ │ │ └── integration_test.rs │ │ │ └── Cargo.toml │ │ ├── ch11_6 │ │ │ ├── src │ │ │ │ └── lib.rs │ │ │ └── Cargo.toml │ │ ├── ch11_1 │ │ │ └── Cargo.toml │ │ ├── ch11_2 │ │ │ └── Cargo.toml │ │ ├── ch11_3 │ │ │ └── Cargo.toml │ │ ├── ch11_4 │ │ │ └── Cargo.toml │ │ └── ch11_5 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ └── lib.rs │ ├── ch1 │ │ └── ch1_1 │ │ │ ├── src │ │ │ └── main.rs │ │ │ └── Cargo.toml │ ├── ch14 │ │ ├── adder │ │ │ ├── add-two │ │ │ │ ├── src │ │ │ │ │ └── lib.rs │ │ │ │ └── Cargo.toml │ │ │ ├── add-one │ │ │ │ ├── Cargo.toml │ │ │ │ └── src │ │ │ │ │ └── lib.rs │ │ │ ├── src │ │ │ │ └── main.rs │ │ │ └── Cargo.toml │ │ ├── ch14_1 │ │ │ └── Cargo.toml │ │ └── art1 │ │ │ ├── src │ │ │ └── main.rs │ │ │ └── Cargo.toml │ ├── ch17 │ │ ├── blog │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── blog2 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch17_1 │ │ │ └── Cargo.toml │ │ ├── ch17_2 │ │ │ └── Cargo.toml │ │ ├── ch17_3 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── lib.rs │ │ ├── ch17_4 │ │ │ └── Cargo.toml │ │ ├── rust_gui │ │ │ └── Cargo.toml │ │ └── ch17_5 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ └── lib.rs │ ├── ch20 │ │ ├── hello │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── hello1 │ │ │ └── Cargo.toml │ │ ├── hello2 │ │ │ └── Cargo.toml │ │ ├── hello3 │ │ │ ├── Cargo.toml │ │ │ └── hello.html │ │ ├── hello4 │ │ │ ├── Cargo.toml │ │ │ ├── hello.html │ │ │ └── 404.html │ │ ├── hello5 │ │ │ ├── Cargo.toml │ │ │ ├── hello.html │ │ │ └── 404.html │ │ ├── hello6 │ │ │ ├── Cargo.toml │ │ │ ├── hello.html │ │ │ └── 404.html │ │ ├── hello7 │ │ │ ├── Cargo.toml │ │ │ ├── hello.html │ │ │ └── 404.html │ │ ├── hello10 │ │ │ ├── Cargo.toml │ │ │ ├── hello.html │ │ │ └── 404.html │ │ ├── hello11 │ │ │ ├── Cargo.toml │ │ │ ├── hello.html │ │ │ └── 404.html │ │ ├── hello12 │ │ │ ├── Cargo.toml │ │ │ ├── hello.html │ │ │ └── 404.html │ │ ├── hello13 │ │ │ ├── Cargo.toml │ │ │ ├── hello.html │ │ │ └── 404.html │ │ ├── hello14 │ │ │ ├── Cargo.toml │ │ │ ├── hello.html │ │ │ └── 404.html │ │ ├── hello15 │ │ │ ├── Cargo.toml │ │ │ ├── hello.html │ │ │ └── 404.html │ │ ├── hello16 │ │ │ ├── Cargo.toml │ │ │ ├── hello.html │ │ │ └── 404.html │ │ ├── hello17 │ │ │ ├── Cargo.toml │ │ │ ├── hello.html │ │ │ └── 404.html │ │ ├── hello18 │ │ │ ├── Cargo.toml │ │ │ ├── hello.html │ │ │ └── 404.html │ │ ├── hello19 │ │ │ ├── Cargo.toml │ │ │ ├── hello.html │ │ │ └── 404.html │ │ ├── hello20 │ │ │ ├── Cargo.toml │ │ │ ├── hello.html │ │ │ └── 404.html │ │ ├── hello21 │ │ │ ├── Cargo.toml │ │ │ ├── hello.html │ │ │ └── 404.html │ │ ├── hello8 │ │ │ ├── Cargo.toml │ │ │ ├── hello.html │ │ │ └── 404.html │ │ └── hello9 │ │ │ ├── Cargo.toml │ │ │ ├── hello.html │ │ │ └── 404.html │ ├── ch5 │ │ ├── ch5_1 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch5_2 │ │ │ └── Cargo.toml │ │ ├── ch5_3 │ │ │ └── Cargo.toml │ │ ├── ch5_6 │ │ │ └── Cargo.toml │ │ ├── ch5_7 │ │ │ └── Cargo.toml │ │ ├── ch5_8 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch5_9 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch5_10 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch5_13 │ │ │ └── Cargo.toml │ │ ├── ch5_13_1 │ │ │ └── Cargo.toml │ │ ├── ch5_15 │ │ │ └── Cargo.toml │ │ ├── ch5_16 │ │ │ └── Cargo.toml │ │ ├── ch5_7_1 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ └── ch5_7_2 │ │ │ └── Cargo.toml │ ├── ch6 │ │ ├── ch6_1 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ └── ch6_2 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ └── main.rs │ ├── aggregator │ │ └── Cargo.toml │ ├── ch16 │ │ ├── ch16_1 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch16_10 │ │ │ └── Cargo.toml │ │ ├── ch16_11 │ │ │ └── Cargo.toml │ │ ├── ch16_12 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch16_2 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch16_3 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch16_4 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch16_5 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch16_6 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch16_7 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch16_8 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch16_9 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ │ └── main.rs │ │ ├── ch16_13_1 │ │ │ └── Cargo.toml │ │ ├── ch16_13_2 │ │ │ └── Cargo.toml │ │ ├── ch16_13_3 │ │ │ └── Cargo.toml │ │ ├── ch16_13_4 │ │ │ └── Cargo.toml │ │ └── ch16_13_5 │ │ │ └── Cargo.toml │ ├── appendix │ │ ├── ap07_1 │ │ │ └── Cargo.toml │ │ └── ap07_2 │ │ │ ├── Cargo.toml │ │ │ └── src │ │ │ └── main.rs │ ├── thehydroimpulse │ │ └── Cargo.toml │ └── ch2 │ │ └── guessing_game2 │ │ ├── Cargo.toml │ │ └── guessing_game │ │ └── Cargo.toml ├── src │ ├── img │ │ ├── trpl14-03.png │ │ ├── trpl14-05.png │ │ ├── trpl14-07.png │ │ ├── trpl14-10.png │ │ └── trpl20-01.png │ ├── appendix-00.md │ └── ch17-00-oop.md ├── nostarch │ └── odt │ │ ├── chapter02.doc │ │ ├── chapter03.docx │ │ ├── chapter04.docx │ │ ├── chapter05.docx │ │ ├── chapter06.docx │ │ ├── chapter07.docx │ │ ├── chapter08.docx │ │ ├── chapter09.docx │ │ ├── chapter11.docx │ │ └── chapter12.docx └── book.toml ├── .gitignore ├── ci └── stable-check │ ├── Cargo.lock │ └── Cargo.toml ├── .gitattributes ├── redirects ├── compiler-plugins.md ├── if.md ├── drop.md ├── enums.md ├── ffi.md ├── loops.md ├── match.md ├── ufcs.md ├── if-let.md ├── macros.md ├── strings.md ├── structs.md ├── testing.md ├── traits.md ├── unsafe.md └── vectors.md └── .travis.yml /first-edition/src/chapter_1.md: -------------------------------------------------------------------------------- 1 | # Chapter 1 2 | -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch9/ch9_4/hello.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_19/src/main.rs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /second-edition/examples/ch4/ch4_13/src/main.rs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch9/ch9_3/hello.txt: -------------------------------------------------------------------------------- 1 | test -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch9/ch9_8/hello.txt: -------------------------------------------------------------------------------- 1 | Hello! -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | book/ 2 | *~ 3 | .idea 4 | .DS_Store 5 | target 6 | tmp 7 | .gitignore 8 | 9 | -------------------------------------------------------------------------------- /ci/stable-check/Cargo.lock: -------------------------------------------------------------------------------- 1 | [root] 2 | name = "stable-check" 3 | version = "0.1.0" 4 | 5 | -------------------------------------------------------------------------------- /second-edition/examples/ch7/communicator/src/client.rs: -------------------------------------------------------------------------------- 1 | 2 | pub fn connect() { 3 | } 4 | -------------------------------------------------------------------------------- /second-edition/examples/ch7/communicator/src/network/server.rs: -------------------------------------------------------------------------------- 1 | pub fn connect() { 2 | } -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch9/ch9_1/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | panic!("crash and burn"); 3 | } -------------------------------------------------------------------------------- /second-edition/examples/ch12/minigrep12/output.txt: -------------------------------------------------------------------------------- 1 | Problem parsing arguments: not enough arguments 2 | -------------------------------------------------------------------------------- /second-edition/examples/ch12/minigrep13/output.txt: -------------------------------------------------------------------------------- 1 | Are you nobody, too? 2 | How dreary to be somebody! 3 | -------------------------------------------------------------------------------- /second-edition/examples/ch13/minigrep13_1/output.txt: -------------------------------------------------------------------------------- 1 | Are you nobody, too? 2 | How dreary to be somebody! 3 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_15/src/main.rs: -------------------------------------------------------------------------------- 1 | pub struct Ref<'a, T>(&'a T); 2 | 3 | fn main() {} 4 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_16/src/main.rs: -------------------------------------------------------------------------------- 1 | pub struct Ref<'a, T: 'a>(&'a T); 2 | 3 | fn main() {} 4 | -------------------------------------------------------------------------------- /second-edition/examples/ch7/communicator/src/network/mod.rs: -------------------------------------------------------------------------------- 1 | pub fn connect() { 2 | } 3 | pub mod server; 4 | -------------------------------------------------------------------------------- /first-edition/book.toml: -------------------------------------------------------------------------------- 1 | title = "The Rust Programming Language" 2 | author = "The Rust Project Developers" 3 | -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch9/pr9_panic1/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let v = vec![1, 2, 3]; 3 | 4 | v[100]; 5 | } 6 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_17/src/main.rs: -------------------------------------------------------------------------------- 1 | pub struct StaticRef(&'static T); 2 | 3 | fn main() {} 4 | -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_2/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let v = vec![1, 2, 3]; 3 | println!("{:?}",v); 4 | } -------------------------------------------------------------------------------- /second-edition/examples/ch15/ch15_1/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let b = Box::new(5); 3 | println!("b = {}", b); 4 | } -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_1/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let v: Vec = Vec::new(); 3 | print!("{:?} ", v); 4 | } -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_3/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let v = vec![1, 2, (3 as u64)]; 3 | println!("{:?}",v); 4 | } -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_6/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let v = vec![1, 2, 3, 4, 5]; 3 | println!("{}", v[100]); 4 | } -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_18/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let _x = 5; 3 | let y = 10; 4 | println!("{}", y); 5 | } 6 | -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_5/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | if let x = 5 { 3 | println!("{}", x); 4 | }; 5 | } 6 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_33/src/main.rs: -------------------------------------------------------------------------------- 1 | pub fn returns_closure() -> Fn(i32) -> i32 { 2 | |x| x + 1 3 | } 4 | fn main() {} 5 | -------------------------------------------------------------------------------- /second-edition/src/img/trpl14-03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rust-lang-ru/rust_book_2ed/HEAD/second-edition/src/img/trpl14-03.png -------------------------------------------------------------------------------- /second-edition/src/img/trpl14-05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rust-lang-ru/rust_book_2ed/HEAD/second-edition/src/img/trpl14-05.png -------------------------------------------------------------------------------- /second-edition/src/img/trpl14-07.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rust-lang-ru/rust_book_2ed/HEAD/second-edition/src/img/trpl14-07.png -------------------------------------------------------------------------------- /second-edition/src/img/trpl14-10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rust-lang-ru/rust_book_2ed/HEAD/second-edition/src/img/trpl14-10.png -------------------------------------------------------------------------------- /second-edition/src/img/trpl20-01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rust-lang-ru/rust_book_2ed/HEAD/second-edition/src/img/trpl20-01.png -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_15_1/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let len = String::from("Hola").len(); 3 | println!("{}", len); 4 | } -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_16/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | for c in "नमस्ते".chars() { 3 | println!("{}", c); 4 | } 5 | } -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_17/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | for b in "नमस्ते".bytes() { 3 | println!("{}", b); 4 | } 5 | } -------------------------------------------------------------------------------- /second-edition/examples/ch11/adder/tests/common/mod.rs: -------------------------------------------------------------------------------- 1 | pub fn setup() { 2 | // setup code specific to your library's tests would go here 3 | } -------------------------------------------------------------------------------- /second-edition/examples/ch7/communicator/src/main.rs: -------------------------------------------------------------------------------- 1 | extern crate communicator; 2 | 3 | fn main() { 4 | communicator::client::connect(); 5 | } -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_15_2/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let len = String::from("Здравствуйте").len(); 3 | println!("{}", len); 4 | } -------------------------------------------------------------------------------- /second-edition/nostarch/odt/chapter02.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rust-lang-ru/rust_book_2ed/HEAD/second-edition/nostarch/odt/chapter02.doc -------------------------------------------------------------------------------- /second-edition/nostarch/odt/chapter03.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rust-lang-ru/rust_book_2ed/HEAD/second-edition/nostarch/odt/chapter03.docx -------------------------------------------------------------------------------- /second-edition/nostarch/odt/chapter04.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rust-lang-ru/rust_book_2ed/HEAD/second-edition/nostarch/odt/chapter04.docx -------------------------------------------------------------------------------- /second-edition/nostarch/odt/chapter05.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rust-lang-ru/rust_book_2ed/HEAD/second-edition/nostarch/odt/chapter05.docx -------------------------------------------------------------------------------- /second-edition/nostarch/odt/chapter06.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rust-lang-ru/rust_book_2ed/HEAD/second-edition/nostarch/odt/chapter06.docx -------------------------------------------------------------------------------- /second-edition/nostarch/odt/chapter07.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rust-lang-ru/rust_book_2ed/HEAD/second-edition/nostarch/odt/chapter07.docx -------------------------------------------------------------------------------- /second-edition/nostarch/odt/chapter08.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rust-lang-ru/rust_book_2ed/HEAD/second-edition/nostarch/odt/chapter08.docx -------------------------------------------------------------------------------- /second-edition/nostarch/odt/chapter09.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rust-lang-ru/rust_book_2ed/HEAD/second-edition/nostarch/odt/chapter09.docx -------------------------------------------------------------------------------- /second-edition/nostarch/odt/chapter11.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rust-lang-ru/rust_book_2ed/HEAD/second-edition/nostarch/odt/chapter11.docx -------------------------------------------------------------------------------- /second-edition/nostarch/odt/chapter12.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rust-lang-ru/rust_book_2ed/HEAD/second-edition/nostarch/odt/chapter12.docx -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_34/src/main.rs: -------------------------------------------------------------------------------- 1 | pub fn returns_closure() -> Box i32> { 2 | Box::new(|x| x + 1) 3 | } 4 | fn main() {} 5 | -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_14/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let s1 = String::from("hello"); 3 | let h = s1[0]; 4 | println!("{}", h); 5 | } -------------------------------------------------------------------------------- /second-edition/examples/ch1/ch1_1/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | println!("Hello, Rust world! Привет, Мир!"); 3 | println!("Hello! Привет!"); 4 | } 5 | -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_15/src/main.rs: -------------------------------------------------------------------------------- 1 | fn foo(_: i32) { 2 | println!("{}", 3); 3 | } 4 | 5 | fn main() { 6 | foo(19); 7 | foo(62); 8 | } -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_10/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut s = String::from("foo"); 3 | s.push_str("bar"); 4 | println!("{}", s); 5 | } -------------------------------------------------------------------------------- /second-edition/book.toml: -------------------------------------------------------------------------------- 1 | title = "The Rust Programming Language" 2 | author = "Steve Klabnik and Carol Nichols, with Contributions from the Rust Community" 3 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_7/src/main.rs: -------------------------------------------------------------------------------- 1 | static HELLO_WORLD: &str = "Hello, world!"; 2 | 3 | fn main() { 4 | println!("name is: {}", HELLO_WORLD); 5 | } -------------------------------------------------------------------------------- /ci/stable-check/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "stable-check" 3 | version = "0.1.0" 4 | authors = ["steveklabnik "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch7/secret/src/lib.rs: -------------------------------------------------------------------------------- 1 | #[cfg(test)] 2 | mod tests { 3 | #[test] 4 | fn it_works() { 5 | assert_eq!(2 + 2, 4); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Set the default behavior, in case people don't have core.autocrlf set. 2 | * text=auto eol=lf 3 | *.docx binary 4 | *.odt binary 5 | *.png binary 6 | 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch10_27_1/src/main.rs: -------------------------------------------------------------------------------- 1 | 2 | fn main() { 3 | let s: &'static str = "I have a static lifetime."; 4 | 5 | println!("{}", s); 6 | 7 | } 8 | -------------------------------------------------------------------------------- /second-edition/examples/ch11/ch11_6/src/lib.rs: -------------------------------------------------------------------------------- 1 | #[cfg(test)] 2 | mod tests { 3 | #[test] 4 | fn it_works() { 5 | assert_eq!(2 + 2, 4); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /second-edition/examples/ch15/ch15_10/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut s = String::from("hello"); 3 | 4 | let _r1 = &mut s; 5 | let _r2 = &mut s; 6 | } 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch15/ch15_6/src/lib.rs: -------------------------------------------------------------------------------- 1 | #[cfg(test)] 2 | mod tests { 3 | #[test] 4 | fn it_works() { 5 | assert_eq!(2 + 2, 4); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /second-edition/examples/ch15/ch15_6_1/src/lib.rs: -------------------------------------------------------------------------------- 1 | #[cfg(test)] 2 | mod tests { 3 | #[test] 4 | fn it_works() { 5 | assert_eq!(2 + 2, 4); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_19/src/main.rs: -------------------------------------------------------------------------------- 1 | pub trait Iterator { 2 | type Item; 3 | fn next(&mut self) -> Option; 4 | } 5 | 6 | fn main() {} 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_5/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let spaces = " "; 3 | let spaces = spaces.len(); 4 | 5 | println!("The lenth is {}", spaces); 6 | } -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_7/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let guess 3 | : u32 4 | = "42".parse().expect("Not a number!"); 5 | println!("guess = {}",guess); 6 | } -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch9/ch9_10/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::fs::File; 2 | 3 | fn main() { 4 | let f = File::open("hello.txt")?; 5 | //println!("Hello, world!"); 6 | } -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch9/ch9_5/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::fs::File; 2 | 3 | fn main() { 4 | let f = File::open("hello.txt").unwrap(); 5 | print!("{:#?}", f); 6 | } 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch13/ch13_5/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::vec::Vec; 2 | 3 | fn main() { 4 | let v1: Vec = vec![1, 2, 3]; 5 | 6 | v1.iter().map(|x| x + 1); 7 | } 8 | -------------------------------------------------------------------------------- /second-edition/examples/ch14/adder/add-two/src/lib.rs: -------------------------------------------------------------------------------- 1 | #[cfg(test)] 2 | mod tests { 3 | #[test] 4 | fn it_works() { 5 | assert_eq!(2 + 2, 4); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /second-edition/examples/ch1/ch1_1/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ex1" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch11/adder/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "adder" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch17/blog/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "blog" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch17/blog2/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "blog2" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hello" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_1/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch3_1" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_2/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch3_2" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_29/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | another_function(5); 3 | } 4 | 5 | fn another_function(x: i32) { 6 | println!("The value of x is: {}", x); 7 | } -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_3/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch3_3" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_4/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch3_4" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_5/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch3_5" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_6/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch3_6" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_7/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch3_7" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_8/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch3_8" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_9/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch3_9" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch4/ch4_1/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch4_1" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch4/ch4_2/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch4_2" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch4/ch4_3/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch4_3" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch4/ch4_4/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch4_4" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch4/ch4_5/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch4_5" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch4/ch4_6/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch4_6" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch4/ch4_7/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch4_7" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch4/ch4_8/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch4_8" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch4/ch4_9/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch4_9" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch5/ch5_1/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch5_1" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch5/ch5_2/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch5_2" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch5/ch5_3/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch5_3" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch5/ch5_6/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch5_6" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch5/ch5_7/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch5_7" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch5/ch5_8/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch5_8" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch5/ch5_9/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch5_9" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch6/ch6_1/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch6_1" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch6/ch6_2/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch6_2" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch7/ch7_1/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch7_1" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch7/ch7_2/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch7_2" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch7/ch7_3/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch7_3" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch7/ch7_4/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch7_4" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch7/ch7_5/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch7_5" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch7/ch7_6/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch7_6" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_1/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch8_1" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_2/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch8_2" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_3/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch8_3" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_4/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch8_4" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_5/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch8_5" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_6/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch8_6" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_7/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch8_7" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_8/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch8_8" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_9/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch8_9" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/aggregator/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "aggregator" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch10_1/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch10_1" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch10_18/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch10_18" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch10_2/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch10_2" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch10_20/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch10_20" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch10_21/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch10_21" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch10_22/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch10_22" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch10_23/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch10_23" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch10_24/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch10_23" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch10_25/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch10_23" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch10_26/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch10_23" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch10_27/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch10_27" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch10_3/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch10_3" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch10_4/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch10_4" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch10_5/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch10_5" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch10_6/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch10_6" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch10_7/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch10_7" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch10_8/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch10_8" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch9/ch9_1/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch9_1" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch9/ch9_2/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch9_2" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch9/ch9_3/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch9_3" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch9/ch9_4/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch9_4" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch9/ch9_5/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch9_5" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch9/ch9_6/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch9_6" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch9/ch9_7/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch9_7" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch9/ch9_8/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch9_8" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch9/ch9_9/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch9_9" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch11/ch11_1/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch11_1" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch11/ch11_2/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch11_2" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch11/ch11_3/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch11_3" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch11/ch11_4/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch11_4" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch11/ch11_5/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch11_5" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch11/ch11_6/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch11_6" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch13/ch13_1/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch13_1" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch13/ch13_2/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch13_2" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch13/ch13_3/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch13_3" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch13/ch13_4/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch13_4" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch13/ch13_5/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch13_5" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch13/ch13_6/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch13_6" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch13/ch13_7/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch13_7" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch13/ch13_8/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch13_8" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch14/ch14_1/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch14_1" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch15/ch15_1/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch15_1" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch15/ch15_10/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch15_10" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch15/ch15_11/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch15_11" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch15/ch15_12/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch15_12" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch15/ch15_2/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch15_2" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch15/ch15_3/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch15_3" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch15/ch15_4/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch15_4" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch15/ch15_5/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch15_5" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch15/ch15_6/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch15_6" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch15/ch15_7/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch15_7" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch15/ch15_8/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch15_8" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch15/ch15_9/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch15_9" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch16/ch16_1/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch16_1" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch16/ch16_10/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch16_10" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch16/ch16_11/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch16_11" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch16/ch16_12/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch16_12" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch16/ch16_2/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch16_2" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch16/ch16_3/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch16_3" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch16/ch16_4/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch16_4" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch16/ch16_5/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch16_5" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch16/ch16_6/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch16_6" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch16/ch16_7/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch16_7" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch16/ch16_8/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch16_8" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch16/ch16_9/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch16_9" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch17/ch17_1/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch17_1" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch17/ch17_2/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch17_2" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch17/ch17_3/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch17_2" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch17/ch17_4/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch17_2" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_1/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch18_1" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_10/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch18_10" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_11/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch18_11" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_12/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch18_12" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_13/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch18_13" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_14/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch18_14" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_15/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch18_15" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_16/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch18_16" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_17/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch18_17" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_18/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch18_18" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_19/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch18_19" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_2/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch18_2" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_20/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch18_20" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_21/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch18_21" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_22/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch18_22" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_23/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch18_23" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_24/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch18_24" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_25/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch18_25" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_26/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch18_26" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_27/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch18_27" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_28/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch18_28" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_3/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch18_3" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_4/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch18_4" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_5/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch18_5" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_6/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch18_6" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_7/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch18_7" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_8/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch18_8" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_9/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch18_9" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_1/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch19_1" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_10/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch19_10" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_11/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch19_11" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_12/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch19_12" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_13/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch19_13" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_14/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch19_14" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_15/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch19_15" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_16/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch19_16" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_17/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch19_17" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_18/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch19_18" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_19/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch19_19" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_2/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch19_2" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_20/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch19_20" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_21/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch19_21" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_22/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch19_22" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_23/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch19_23" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_24/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch19_24" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_25/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch19_25" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_26/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch19_26" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_27/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch19_27" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_28/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch19_28" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_29/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch19_29" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_3/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch19_3" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_30/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch19_30" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_31/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch19_31" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_32/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch19_32" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_33/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch19_33" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_34/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch19_34" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_4/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch19_4" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_5/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch19_5" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_6/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch19_6" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_7/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch19_7" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_8/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch19_8" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_9/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch19_9" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello1/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hello" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello2/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hello2" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello3/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hello3" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello4/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hello4" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello5/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hello4" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello6/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hello4" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello7/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hello4" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_1/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x = 5; 3 | println!("The value of x is: {}", x); 4 | x = 6; 5 | println!("The value of x is: {}", x); 6 | } -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_10/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch3_10" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_11/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch3_11" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_12/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch3_12" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_13/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch3_13" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_14/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch3_14" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_15/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch3_15" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_16/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch3_16" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_17/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch3_17" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_18/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch3_18" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_19/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch3_19" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_20/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch3_20" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_21/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch3_21" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_22/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch3_22" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_23/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch3_23" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_24/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch3_24" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_25/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch3_25" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_26/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch3_26" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_27/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch3_27" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_28/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch3_28" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_29/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch3_29" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_30/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch3_30" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_31/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch3_31" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_32/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch3_32" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_33/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch3_33" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_34/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch3_34" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_4/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x = 5; 3 | 4 | let x = x + 1; 5 | 6 | let x = x * 2; 7 | 8 | println!("The value of x is: {}", x); 9 | } -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_8/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let guess: 3 | //u32 4 | i32 5 | = "-42".parse().expect("Not a number!"); 6 | println!("guess = {}",guess); 7 | } -------------------------------------------------------------------------------- /second-edition/examples/ch4/ch4_10/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch4_10" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch4/ch4_11/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch4_11" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch4/ch4_12/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch4_12" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch4/ch4_13/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch4_13" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch4/ch4_14/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch4_14" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch4/ch4_15/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch4_15" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch4/ch4_16/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch4_16" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch4/ch4_17/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch4_17" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch4/ch4_18/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch4_18" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch5/ch5_10/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch5_10" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch5/ch5_13/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch5_13" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch5/ch5_13_1/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch5_13_1" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch5/ch5_15/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch5_15" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch5/ch5_16/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch5_16" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch5/ch5_7_1/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch5_7_1" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch5/ch5_7_2/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch5_7_2" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch7/secret/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "secret" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_10/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch8_10" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_11/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch8_11" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_12/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch8_12" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_13/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch8_13" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_14/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch8_14" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_15_1/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch8_15_1" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_15_2/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch8_15_2" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_16/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch8_16" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_17/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch8_17" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_18/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch8_18" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_19/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch8_19" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_20/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch8_20" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_21/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch8_21" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_22/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch8_22" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_23/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch8_23" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_24/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch8_24" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_25/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch8_25" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/appendix/ap07_1/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ap07_1" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/appendix/ap07_2/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ap07_2" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch10_18/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main(){ 2 | let r; 3 | 4 | { 5 | let x = 5; 6 | r = &x; 7 | } 8 | 9 | println!("r: {}", r); 10 | } -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch10_25_1/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch10_23" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch10_25_2/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch10_23" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch10_27_1/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch10_27_1" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch10_27_2/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch10_27_2" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch9/ch9_10/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch9_10" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch9/ch9_11/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch9_11" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch12/minigrep/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "minigrep" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch12/minigrep1/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "minigrep1" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch12/minigrep10/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "minigrep10" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch12/minigrep11/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "minigrep11" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch12/minigrep12/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "minigrep12" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch12/minigrep13/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "minigrep13" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch12/minigrep2/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "minigrep2" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch12/minigrep3/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "minigrep3" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch12/minigrep4/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "minigrep4" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch12/minigrep5/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "minigrep5" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch12/minigrep6/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "minigrep6" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch12/minigrep7/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "minigrep7" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch12/minigrep8/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "minigrep8" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch12/minigrep9/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "minigrep9" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch14/adder/add-two/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "add-two" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch15/ch15_6_1/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch15_6_1" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch15/ch15_6_2/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch15_6_2" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch16/ch16_13_1/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch16_13" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch16/ch16_13_2/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch16_13" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch16/ch16_13_3/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch16_13" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch16/ch16_13_4/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch16_13" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch16/ch16_13_5/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch16_13" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch17/rust_gui/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rust_gui" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_2/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut x = 5; 3 | println!("The value of x is: {}", x); 4 | x = 6; 5 | println!("The value of x is: {}", x); 6 | } -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_7/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut v = vec![1, 2, 3, 4, 5]; 3 | 4 | let first = &v[0]; 5 | 6 | v.push(6); 7 | println!("{:?}", v); 8 | } 9 | -------------------------------------------------------------------------------- /second-edition/src/appendix-00.md: -------------------------------------------------------------------------------- 1 | # Дополнительная информация 2 | 3 | Следующие секции содержат материалы, которые будут полезны вам во время изучения 4 | и дальнейшего использования Rust. 5 | -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch9/ch9_11/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::net::IpAddr; 2 | 3 | fn main() { 4 | 5 | let home = "127.0.0.1".parse::().unwrap(); 6 | println!("{}", home); 7 | } -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch9/ch9_6/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::fs::File; 2 | 3 | fn main() { 4 | let f = File::open("hello.txt").expect("Failed to open hello.txt"); 5 | print!("{:?}", f); 6 | } -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch9/pr9_panic1/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "pr9_panic1" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch13/ch13_1/src/main.rs: -------------------------------------------------------------------------------- 1 | extern crate ch13_1; 2 | 3 | fn main() { 4 | let resut = ch13_1::simulated_expensive_calculation(1); 5 | 6 | println!("{}", resut); 7 | } 8 | -------------------------------------------------------------------------------- /second-edition/examples/ch13/minigrep13_1/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "minigrep13_1" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_6/src/main.rs: -------------------------------------------------------------------------------- 1 | #[no_mangle] 2 | pub extern "C" fn call_from_c() { 3 | println!("Just called a Rust function from C!"); 4 | } 5 | fn main() { 6 | 7 | } 8 | -------------------------------------------------------------------------------- /second-edition/examples/ch7/communicator/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "communicator" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch10_weather_forecast/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch10_12" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_33/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x = plus_one(5); 3 | 4 | println!("The value of x is: {}", x); 5 | } 6 | 7 | fn plus_one(x: i32) -> i32 { 8 | x + 1; 9 | } -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch9/ch9_12/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch9_12" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | rand = "0.3.14" -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_28/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | type Kilometers = i32; 3 | 4 | let x: i32 = 5; 5 | let y: Kilometers = 5; 6 | 7 | println!("x + y = {}", x + y); 8 | } 9 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_22/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let tup = (500, 6.4, 1); 3 | 4 | let (x, y, z) = tup; 5 | 6 | println!("The value of (x,y,z) is: ({},{},{})", x, y, z); 7 | } 8 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_24/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let a = [1, 2, 3, 4, 5]; 3 | let b: [u8; 5] = [1, 2, 3, 4, 5]; 4 | println!("a is: {:?}", a); 5 | println!("b is: {:?}", b); 6 | } -------------------------------------------------------------------------------- /second-edition/examples/ch4/ch4_2/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let s1 = String::from("hello"); 3 | let s2 = s1; 4 | 5 | println!("{}, world!", s1); 6 | println!("{}, world!", s2); 7 | } 8 | -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch9/ch9_2/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::fs::File; 2 | 3 | fn main() { 4 | let f = File::open("hello.txt"); 5 | //let f: u32 = File::open("hello.txt"); 6 | println!("{:?}",f); 7 | } 8 | -------------------------------------------------------------------------------- /second-edition/examples/ch14/adder/add-one/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "add-one" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | 8 | rand = "0.3.14" -------------------------------------------------------------------------------- /second-edition/examples/thehydroimpulse/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | 3 | name = "merkle" 4 | version = "0.0.1" 5 | authors = ["Daniel Fagnan "] 6 | 7 | [dependencies] 8 | rust-crypto = "^0.2" 9 | -------------------------------------------------------------------------------- /second-edition/examples/ch11/ch11_5/src/lib.rs: -------------------------------------------------------------------------------- 1 | #[test] 2 | fn it_works() { 3 | assert!(true); 4 | } 5 | 6 | #[test] 7 | #[ignore] 8 | fn expensive_test() { 9 | // code that takes an hour to run 10 | } -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_32/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x = plus_one(5); 3 | 4 | println!("The value of x is: {}", x); 5 | } 6 | 7 | fn plus_one(x: i32) -> i32 { 8 | x + 1 9 | } 10 | -------------------------------------------------------------------------------- /second-edition/examples/ch4/ch4_6/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let s = String::from("hello"); 3 | 4 | change(&s); 5 | } 6 | 7 | fn change(some_string: &String) { 8 | some_string.push_str(", world"); 9 | } -------------------------------------------------------------------------------- /second-edition/examples/ch14/adder/src/main.rs: -------------------------------------------------------------------------------- 1 | extern crate add_one; 2 | extern crate rand; 3 | 4 | fn main() { 5 | let num = 10; 6 | println!("Hello, world! {} plus one is {}!", num, add_one::add_one(num)); 7 | } -------------------------------------------------------------------------------- /second-edition/examples/ch2/guessing_game2/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "guessing_game" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | 8 | rand = "0.3.14" -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_26/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let a = [1, 2, 3, 4, 5]; 3 | let first = a[0]; 4 | let second = a[1]; 5 | 6 | println!("first = {}, second = {}", first, second); 7 | } 8 | -------------------------------------------------------------------------------- /second-edition/examples/ch15/ch15_11/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::cell::RefCell; 2 | 3 | fn main() { 4 | let s = RefCell::new(String::from("hello")); 5 | 6 | let _r1 = s.borrow_mut(); 7 | let _r2 = s.borrow_mut(); 8 | } -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_9/src/main.rs: -------------------------------------------------------------------------------- 1 | unsafe trait Foo { 2 | // methods go here 3 | } 4 | 5 | unsafe impl Foo for i32 { 6 | // method implementations go here 7 | } 8 | 9 | fn main() { 10 | 11 | } -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_27/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let a = [1, 2, 3, 4, 5]; 3 | let index = 10; 4 | 5 | let element = a[index]; 6 | 7 | println!("The value of element is: {}", element); 8 | } 9 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_28/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | println!("Hello, world!"); 3 | 4 | another_function(); 5 | } 6 | 7 | fn another_function() { 8 | println!("Another function."); 9 | } 10 | -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_4/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | //let mut v = Vec::new(); 3 | let mut v = vec![]; 4 | v.push(5); 5 | v.push(6); 6 | v.push(7); 7 | v.push(8); 8 | println!("{:?}",v); 9 | } -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_16/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x = Some(5); 3 | 4 | match x { 5 | Some(_) => println!("got a Some and I don't care what's inside"), 6 | None => (), 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /second-edition/examples/ch2/guessing_game2/guessing_game/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "guessing_game" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | 8 | rand = "0.3.14" -------------------------------------------------------------------------------- /second-edition/examples/ch4/ch4_15/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let s = String::from("hello"); 3 | 4 | let slice = &s[0..2]; 5 | println!("{}", slice); 6 | let slice = &s[..2]; 7 | println!("{}", slice); 8 | } 9 | -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_27/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x = 4; 3 | let y = false; 4 | 5 | match x { 6 | 4 | 5 | 6 if y => println!("yes"), 7 | _ => println!("no"), 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /second-edition/examples/ch4/ch4_8/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut s = String::from("hello"); 3 | 4 | let r1 = &mut s; 5 | let r2 = &mut s; 6 | 7 | println!("{}", r1); 8 | println!("{}", r2); 9 | } 10 | -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_8/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut v = vec![1, 2, 3, 4, 5]; 3 | 4 | v.push(6); 5 | let first = &v[0]; 6 | 7 | 8 | println!("{:?}", v); 9 | println!("{}", first); 10 | } 11 | -------------------------------------------------------------------------------- /second-edition/examples/ch17/ch17_5/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "ch17_5" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | rust_gui={path = "../rust_gui", version = "^0.1.0"} 8 | -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_3/src/main.rs: -------------------------------------------------------------------------------- 1 | fn print_coordinates(&(x, y): &(i32, i32)) { 2 | println!("Current location: ({}, {})", x, y); 3 | } 4 | 5 | fn main() { 6 | let point = (3, 5); 7 | print_coordinates(&point); 8 | } -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_5/src/main.rs: -------------------------------------------------------------------------------- 1 | extern "C" { 2 | fn abs(input: i32) -> i32; 3 | } 4 | 5 | fn main() { 6 | unsafe { 7 | println!("Absolute value of -3 according to C: {}", abs(-3)); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /second-edition/examples/ch4/ch4_12/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let reference_to_nothing = dangle(); 3 | println!("{}", reference_to_nothing); 4 | } 5 | 6 | fn dangle() -> String { 7 | let s = String::from("hello"); 8 | s 9 | } -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_21/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let numbers = (2, 4, 8, 16, 32); 3 | 4 | match numbers { 5 | (.., second, ..) => { 6 | println!("Some numbers: {}", second) 7 | }, 8 | } 9 | } -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_4/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let some_option_value: Option = None; 3 | //let Some(x) = some_option_value; 4 | if let Some(x) = some_option_value { 5 | println!("{}", x); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_30/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | another_function(5, 6); 3 | } 4 | 5 | fn another_function(x: i32, y: i32) { 6 | println!("The value of x is: {}", x); 7 | println!("The value of y is: {}", y); 8 | } 9 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_34/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let number = 3; 3 | 4 | if number < 5 { 5 | println!("condition was true"); 6 | } else { 7 | println!("condition was false"); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /second-edition/examples/ch4/ch4_11/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let reference_to_nothing = dangle(); 3 | println!("{}", reference_to_nothing); 4 | } 5 | 6 | fn dangle() -> &String { 7 | let s = String::from("hello"); 8 | &s 9 | } -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_5/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let v = vec![1, 2, 3, 4, 5]; 3 | 4 | let third: &i32 = &v[2]; 5 | println!("{}", third); 6 | let third: Option<&i32> = v.get(2); 7 | println!("{:?}", third); 8 | } -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_17/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let numbers = (2, 4, 8, 16, 32); 3 | 4 | match numbers { 5 | (first, _, third, _, fifth) => println!("Some numbers: {}, {}, {}", first, third, fifth), 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_8/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x = 1; 3 | 4 | match x { 5 | 1 | 2 => println!("one or two"), 6 | 3 => println!("three"), 7 | _ => println!("anything"), 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello10/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hello" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | 8 | [[bin]] 9 | name = "hello" 10 | path = "bin/main.rs" -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello11/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hello" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | 8 | [[bin]] 9 | name = "hello" 10 | path = "bin/main.rs" -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello12/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hello" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | 8 | [[bin]] 9 | name = "hello" 10 | path = "bin/main.rs" -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello13/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hello" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | 8 | [[bin]] 9 | name = "hello" 10 | path = "bin/main.rs" -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello14/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hello" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | 8 | [[bin]] 9 | name = "hello" 10 | path = "bin/main.rs" -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello15/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hello" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | 8 | [[bin]] 9 | name = "hello" 10 | path = "bin/main.rs" -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello16/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hello" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | 8 | [[bin]] 9 | name = "hello" 10 | path = "bin/main.rs" -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello17/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hello" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | 8 | [[bin]] 9 | name = "hello" 10 | path = "bin/main.rs" -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello18/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hello" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | 8 | [[bin]] 9 | name = "hello" 10 | path = "bin/main.rs" -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello19/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hello" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | 8 | [[bin]] 9 | name = "hello" 10 | path = "bin/main.rs" -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello20/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hello" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | 8 | [[bin]] 9 | name = "hello" 10 | path = "bin/main.rs" -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello21/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hello" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | 8 | [[bin]] 9 | name = "hello" 10 | path = "bin/main.rs" -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello8/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hello" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | 8 | [[bin]] 9 | name = "hello" 10 | path = "bin/main.rs" -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello9/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "hello" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [dependencies] 7 | 8 | [[bin]] 9 | name = "hello" 10 | path = "bin/main.rs" -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_11/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut s1 = String::from("foo"); 3 | let s2 = String::from("bar"); 4 | s1.push_str(&s2); 5 | println!("{}", s1); 6 | println!("{}", s2); 7 | println!("{}", s2); 8 | } -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch10_21/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let string1 = String::from("abcd"); 3 | let string2 = "xyz"; 4 | 5 | let result = longest(string1.as_str(), string2); 6 | println!("The longest string is {}", result); 7 | } -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_2/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut stack = Vec::new(); 3 | 4 | stack.push(1); 5 | stack.push(2); 6 | stack.push(3); 7 | 8 | while let Some(top) = stack.pop() { 9 | println!("{}", top); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_20/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let numbers = (2, 4, 8, 16, 32); 3 | 4 | match numbers { 5 | (first, .., last) => { 6 | println!("Some numbers: {}, {}", first, last); 7 | }, 8 | } 9 | } -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_23/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x: (i32, f64, u8) = (500, 6.4, 1); 3 | let v1 = x.0; 4 | let v2 = x.1; 5 | let v3 = x.2; 6 | 7 | println!("The value of (x,y,z) is: ({},{},{})", v1, v2, v3); 8 | } 9 | -------------------------------------------------------------------------------- /second-edition/examples/ch4/ch4_1/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut s = String::from("hello"); 3 | 4 | s.push_str(", world!"); // push_str() appends a literal to a String 5 | 6 | println!("{}", s); // This will print `hello, world!` 7 | } 8 | -------------------------------------------------------------------------------- /second-edition/examples/ch4/ch4_10/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut s = String::from("hello"); 3 | let r1 = &s; 4 | let r2 = &s; 5 | let r3 = &mut s; 6 | println!("{}", r1); 7 | println!("{}", r2); 8 | println!("{}", r3); 9 | } -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_13/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let s1 = String::from("tic"); 3 | let s2 = String::from("tac"); 4 | let s3 = String::from("toe"); 5 | 6 | let s = format!("{}-{}-{}", s1, s2, s3); 7 | println!("{}", s); 8 | } -------------------------------------------------------------------------------- /second-edition/examples/ch13/ch13_6/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::vec::Vec; 2 | 3 | fn main() { 4 | let v1: Vec = vec![1, 2, 3]; 5 | 6 | let v2: Vec<_> = v1.iter().map(|x| x + 1).collect(); 7 | 8 | assert_eq!(v2, vec![2, 3, 4]); 9 | } 10 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_31/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x = 5; 3 | println!("The value of x is: {}", x); 4 | let y = { 5 | let x = 3; 6 | x + 1 7 | }; 8 | 9 | println!("The value of y is: {}", y); 10 | } -------------------------------------------------------------------------------- /second-edition/examples/ch14/adder/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "adder" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | 6 | [workspace] 7 | 8 | [dependencies] 9 | add-one = { path = "add-one" } 10 | rand = "0.3.14" -------------------------------------------------------------------------------- /second-edition/examples/ch16/ch16_4/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::thread; 2 | 3 | fn main() { 4 | let v = vec![1, 2, 3]; 5 | 6 | let handle = thread::spawn(|| { 7 | println!("Here's a vector: {:?}", v); 8 | }); 9 | 10 | handle.join(); 11 | } -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_11/src/main.rs: -------------------------------------------------------------------------------- 1 | struct Point { 2 | x: i32, 3 | y: i32, 4 | } 5 | 6 | fn main() { 7 | let p = Point { x: 0, y: 7 }; 8 | 9 | let Point { x, y } = p; 10 | assert_eq!(0, x); 11 | assert_eq!(7, y); 12 | } -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_3/src/main.rs: -------------------------------------------------------------------------------- 1 | pub fn get_100_000()-> u32 { 2 | 100_000 3 | } 4 | 5 | const MAX_POINTS: u32 = 6 | 100_000 7 | //get_100_000() 8 | //1+1 9 | ; 10 | 11 | fn main() { 12 | println!("MAX_POINTS is: {}", MAX_POINTS); 13 | } -------------------------------------------------------------------------------- /second-edition/examples/ch14/art1/src/main.rs: -------------------------------------------------------------------------------- 1 | extern crate art; 2 | 3 | use art::kinds::PrimaryColor; 4 | use art::utils::mix; 5 | 6 | fn main() { 7 | let red = PrimaryColor::Red; 8 | let yellow = PrimaryColor::Yellow; 9 | mix(red, yellow); 10 | } -------------------------------------------------------------------------------- /second-edition/examples/ch16/ch16_12/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::sync::Mutex; 2 | 3 | fn main() { 4 | let m = Mutex::new(5); 5 | 6 | { 7 | let mut num = m.lock().unwrap(); 8 | *num = 6; 9 | } 10 | 11 | println!("m = {:?}", m); 12 | } -------------------------------------------------------------------------------- /second-edition/examples/ch16/ch16_6/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::thread; 2 | 3 | fn main() { 4 | let v = vec![1, 2, 3]; 5 | 6 | let handle = thread::spawn(move || { 7 | println!("Here's a vector: {:?}", v); 8 | }); 9 | 10 | handle.join(); 11 | } -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_12/src/main.rs: -------------------------------------------------------------------------------- 1 | struct Point { 2 | x: i32, 3 | y: i32, 4 | } 5 | 6 | fn main() { 7 | let p = Point { x: 0, y: 7 }; 8 | 9 | let Point { x: a, y: b } = p; 10 | assert_eq!(0, a); 11 | assert_eq!(7, b); 12 | } -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello10/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello! 6 | 7 | 8 |

Hello!

9 |

Hi from Rust

10 | 11 | -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello11/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello! 6 | 7 | 8 |

Hello!

9 |

Hi from Rust

10 | 11 | -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello12/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello! 6 | 7 | 8 |

Hello!

9 |

Hi from Rust

10 | 11 | -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello13/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello! 6 | 7 | 8 |

Hello!

9 |

Hi from Rust

10 | 11 | -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello14/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello! 6 | 7 | 8 |

Hello!

9 |

Hi from Rust

10 | 11 | -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello15/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello! 6 | 7 | 8 |

Hello!

9 |

Hi from Rust

10 | 11 | -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello16/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello! 6 | 7 | 8 |

Hello!

9 |

Hi from Rust

10 | 11 | -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello17/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello! 6 | 7 | 8 |

Hello!

9 |

Hi from Rust

10 | 11 | -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello18/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello! 6 | 7 | 8 |

Hello!

9 |

Hi from Rust

10 | 11 | -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello19/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello! 6 | 7 | 8 |

Hello!

9 |

Hi from Rust

10 | 11 | -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello20/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello! 6 | 7 | 8 |

Hello!

9 |

Hi from Rust

10 | 11 | -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello21/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello! 6 | 7 | 8 |

Hello!

9 |

Hi from Rust

10 | 11 | -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello3/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello! 6 | 7 | 8 |

Hello!

9 |

Hi from Rust

10 | 11 | -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello4/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello! 6 | 7 | 8 |

Hello!

9 |

Hi from Rust

10 | 11 | -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello5/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello! 6 | 7 | 8 |

Hello!

9 |

Hi from Rust

10 | 11 | -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello6/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello! 6 | 7 | 8 |

Hello!

9 |

Hi from Rust

10 | 11 | -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello7/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello! 6 | 7 | 8 |

Hello!

9 |

Hi from Rust

10 | 11 | -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello8/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello! 6 | 7 | 8 |

Hello!

9 |

Hi from Rust

10 | 11 | -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello9/hello.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello! 6 | 7 | 8 |

Hello!

9 |

Hi from Rust

10 | 11 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_21/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let c: char = 'z'; 3 | let z = 'ℤ'; 4 | let heart_eyed_cat = '😻'; 5 | println!("c = {}", c); 6 | println!("z = {}", z); 7 | println!("heart_eyed_cat = {}", heart_eyed_cat); 8 | } 9 | -------------------------------------------------------------------------------- /second-edition/examples/ch4/ch4_7/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut s = String::from("hello"); 3 | 4 | change(&mut s); 5 | println!("{}", s); 6 | } 7 | 8 | fn change(some_string: &mut String) { 9 | some_string.push_str(", world"); 10 | } 11 | -------------------------------------------------------------------------------- /second-edition/examples/ch13/ch13_1/src/lib.rs: -------------------------------------------------------------------------------- 1 | use std::thread; 2 | use std::time::Duration; 3 | 4 | pub fn simulated_expensive_calculation(intensity: i32) -> i32 { 5 | println!("calculating slowly..."); 6 | thread::sleep(Duration::from_secs(2)); 7 | intensity 8 | } -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_25/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let num = Some(4); 3 | 4 | match num { 5 | Some(x) if x < 5 => println!("less than five: {}", x), 6 | Some(x) => println!("{}", x), 7 | None => (), 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_6/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x = 1; 3 | 4 | match x { 5 | 1 => println!("one"), 6 | 2 => println!("two"), 7 | 3 => println!("three"), 8 | _ => println!("anything"), 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_18/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::collections::HashMap; 2 | 3 | fn main() { 4 | let mut scores = HashMap::new(); 5 | 6 | scores.insert(String::from("Blue"), 10); 7 | scores.insert(String::from("Yellow"), 50); 8 | println!("{:?}", scores); 9 | } -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_2/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut v = vec![1, 2, 3, 4, 5, 6]; 3 | 4 | let r = &mut v[..]; 5 | 6 | let (a, b) = r.split_at_mut(3); 7 | 8 | assert_eq!(a, &mut [1, 2, 3]); 9 | assert_eq!(b, &mut [4, 5, 6]); 10 | } 11 | -------------------------------------------------------------------------------- /second-edition/examples/ch4/ch4_9/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut s = String::from("hello"); 3 | 4 | { 5 | let r1 = &mut s; 6 | println!("{}", r1); 7 | } 8 | { 9 | let r2 = &mut s; 10 | println!("{}", r2); 11 | } 12 | } -------------------------------------------------------------------------------- /second-edition/examples/ch6/ch6_1/src/main.rs: -------------------------------------------------------------------------------- 1 | #[derive(Debug)] 2 | enum IpAddrKind { 3 | V4, 4 | V6, 5 | } 6 | 7 | fn main() { 8 | let four = IpAddrKind::V4; 9 | let six = IpAddrKind::V6; 10 | 11 | println!("{:#?}",four); 12 | println!("{:#?}",six); 13 | } -------------------------------------------------------------------------------- /redirects/compiler-plugins.md: -------------------------------------------------------------------------------- 1 | % The Rust Programming Language Has Moved 2 | 3 | This chapter of the book has moved to [a chapter in the Unstable 4 | Book][unstable book plugins]. Please check it out there. 5 | 6 | [unstable book plugins]: ../unstable-book/language-features/plugin.html 7 | -------------------------------------------------------------------------------- /second-edition/examples/ch16/ch16_7/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::thread; 2 | 3 | fn main() { 4 | let v = vec![1, 2, 3]; 5 | 6 | let handle = thread::spawn(move || { 7 | println!("Here's a vector: {:?}", v); 8 | }); 9 | drop(v); 10 | handle.join(); 11 | } 12 | -------------------------------------------------------------------------------- /second-edition/examples/ch16/ch16_8/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::thread; 2 | use std::sync::mpsc; 3 | 4 | fn main() { 5 | let (tx, rx) = mpsc::channel(); 6 | 7 | thread::spawn(move || { 8 | let val = String::from("hi"); 9 | tx.send(val).unwrap(); 10 | }); 11 | } -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_10/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x = 'c'; 3 | 4 | match x { 5 | 'a'...'j' => println!("early ASCII letter"), 6 | 'k'...'z' => println!("late ASCII letter"), 7 | _ => println!("something else"), 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_21/src/main.rs: -------------------------------------------------------------------------------- 1 | pub trait AGraph { 2 | type Node; 3 | type Edge; 4 | 5 | // methods would go here 6 | } 7 | 8 | 9 | pub fn traverse(_graph: &AGraph) { 10 | // ...snip... 11 | } 12 | 13 | fn main() {} -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_31/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let guess = "3"; 3 | loop { 4 | let _guess: u32 = match guess.trim().parse() { 5 | Ok(num) => num, 6 | Err(_) => continue, 7 | }; 8 | break; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_12/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let s1 = String::from("Hello, "); 3 | let s2 = String::from("world!"); 4 | let s3 = s1 + &s2; // Note that s1 has been moved here and can no longer be used 5 | println!("{}", s3); 6 | //println!("{}", s1); 7 | } -------------------------------------------------------------------------------- /second-edition/examples/ch14/art1/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "art1" 3 | version = "0.1.0" 4 | authors = ["Kosorukov Anatoly "] 5 | description = "A fun game where you guess what number the computer has chosen." 6 | license = "MIT/Apache-2.0" 7 | 8 | [dependencies] 9 | -------------------------------------------------------------------------------- /second-edition/examples/ch4/ch4_5/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let s1 = String::from("hello"); 3 | 4 | let len = calculate_length(&s1); 5 | 6 | println!("The length of '{}' is {}.", s1, len); 7 | } 8 | 9 | fn calculate_length(s: &String) -> usize { 10 | s.len() 11 | } -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_23/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::collections::HashMap; 2 | 3 | fn main() { 4 | let mut scores = HashMap::new(); 5 | 6 | scores.insert(String::from("Blue"), 10); 7 | scores.insert(String::from("Blue"), 25); 8 | 9 | println!("{:?}", scores); 10 | } -------------------------------------------------------------------------------- /second-edition/examples/appendix/ap07_2/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut counter = 0; 3 | 4 | let result = loop { 5 | counter += 1; 6 | 7 | if counter == 10 { 8 | break counter * 2; 9 | } 10 | }; 11 | 12 | assert_eq!(result, 20); 13 | } -------------------------------------------------------------------------------- /second-edition/examples/ch12/minigrep10/poem.txt: -------------------------------------------------------------------------------- 1 | I’m nobody! Who are you? 2 | Are you nobody, too? 3 | Then there’s a pair of us — don’t tell! 4 | They’d banish us, you know. 5 | 6 | How dreary to be somebody! 7 | How public, like a frog 8 | To tell your name the livelong day 9 | To an admiring bog! -------------------------------------------------------------------------------- /second-edition/examples/ch12/minigrep11/poem.txt: -------------------------------------------------------------------------------- 1 | I’m nobody! Who are you? 2 | Are you nobody, too? 3 | Then there’s a pair of us — don’t tell! 4 | They’d banish us, you know. 5 | 6 | How dreary to be somebody! 7 | How public, like a frog 8 | To tell your name the livelong day 9 | To an admiring bog! -------------------------------------------------------------------------------- /second-edition/examples/ch12/minigrep12/poem.txt: -------------------------------------------------------------------------------- 1 | I’m nobody! Who are you? 2 | Are you nobody, too? 3 | Then there’s a pair of us — don’t tell! 4 | They’d banish us, you know. 5 | 6 | How dreary to be somebody! 7 | How public, like a frog 8 | To tell your name the livelong day 9 | To an admiring bog! -------------------------------------------------------------------------------- /second-edition/examples/ch12/minigrep13/poem.txt: -------------------------------------------------------------------------------- 1 | I’m nobody! Who are you? 2 | Are you nobody, too? 3 | Then there’s a pair of us — don’t tell! 4 | They’d banish us, you know. 5 | 6 | How dreary to be somebody! 7 | How public, like a frog 8 | To tell your name the livelong day 9 | To an admiring bog! -------------------------------------------------------------------------------- /second-edition/examples/ch12/minigrep2/poem.txt: -------------------------------------------------------------------------------- 1 | I’m nobody! Who are you? 2 | Are you nobody, too? 3 | Then there’s a pair of us — don’t tell! 4 | They’d banish us, you know. 5 | 6 | How dreary to be somebody! 7 | How public, like a frog 8 | To tell your name the livelong day 9 | To an admiring bog! -------------------------------------------------------------------------------- /second-edition/examples/ch12/minigrep3/poem.txt: -------------------------------------------------------------------------------- 1 | I’m nobody! Who are you? 2 | Are you nobody, too? 3 | Then there’s a pair of us — don’t tell! 4 | They’d banish us, you know. 5 | 6 | How dreary to be somebody! 7 | How public, like a frog 8 | To tell your name the livelong day 9 | To an admiring bog! -------------------------------------------------------------------------------- /second-edition/examples/ch12/minigrep4/poem.txt: -------------------------------------------------------------------------------- 1 | I’m nobody! Who are you? 2 | Are you nobody, too? 3 | Then there’s a pair of us — don’t tell! 4 | They’d banish us, you know. 5 | 6 | How dreary to be somebody! 7 | How public, like a frog 8 | To tell your name the livelong day 9 | To an admiring bog! -------------------------------------------------------------------------------- /second-edition/examples/ch12/minigrep5/poem.txt: -------------------------------------------------------------------------------- 1 | I’m nobody! Who are you? 2 | Are you nobody, too? 3 | Then there’s a pair of us — don’t tell! 4 | They’d banish us, you know. 5 | 6 | How dreary to be somebody! 7 | How public, like a frog 8 | To tell your name the livelong day 9 | To an admiring bog! -------------------------------------------------------------------------------- /second-edition/examples/ch12/minigrep6/poem.txt: -------------------------------------------------------------------------------- 1 | I’m nobody! Who are you? 2 | Are you nobody, too? 3 | Then there’s a pair of us — don’t tell! 4 | They’d banish us, you know. 5 | 6 | How dreary to be somebody! 7 | How public, like a frog 8 | To tell your name the livelong day 9 | To an admiring bog! -------------------------------------------------------------------------------- /second-edition/examples/ch12/minigrep7/poem.txt: -------------------------------------------------------------------------------- 1 | I’m nobody! Who are you? 2 | Are you nobody, too? 3 | Then there’s a pair of us — don’t tell! 4 | They’d banish us, you know. 5 | 6 | How dreary to be somebody! 7 | How public, like a frog 8 | To tell your name the livelong day 9 | To an admiring bog! -------------------------------------------------------------------------------- /second-edition/examples/ch12/minigrep8/poem.txt: -------------------------------------------------------------------------------- 1 | I’m nobody! Who are you? 2 | Are you nobody, too? 3 | Then there’s a pair of us — don’t tell! 4 | They’d banish us, you know. 5 | 6 | How dreary to be somebody! 7 | How public, like a frog 8 | To tell your name the livelong day 9 | To an admiring bog! -------------------------------------------------------------------------------- /second-edition/examples/ch12/minigrep9/poem.txt: -------------------------------------------------------------------------------- 1 | I’m nobody! Who are you? 2 | Are you nobody, too? 3 | Then there’s a pair of us — don’t tell! 4 | They’d banish us, you know. 5 | 6 | How dreary to be somebody! 7 | How public, like a frog 8 | To tell your name the livelong day 9 | To an admiring bog! -------------------------------------------------------------------------------- /second-edition/examples/ch13/ch13_4/src/main.rs: -------------------------------------------------------------------------------- 1 | extern crate ch13_4; 2 | 3 | 4 | fn main() { 5 | let simulated_user_specified_value = 10; 6 | let simulated_random_number = 7; 7 | 8 | ch13_4::generate_workout(simulated_user_specified_value, simulated_random_number); 9 | 10 | } -------------------------------------------------------------------------------- /second-edition/examples/ch13/minigrep13_1/poem.txt: -------------------------------------------------------------------------------- 1 | I’m nobody! Who are you? 2 | Are you nobody, too? 3 | Then there’s a pair of us — don’t tell! 4 | They’d banish us, you know. 5 | 6 | How dreary to be somebody! 7 | How public, like a frog 8 | To tell your name the livelong day 9 | To an admiring bog! -------------------------------------------------------------------------------- /second-edition/examples/ch16/ch16_5/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::thread; 2 | 3 | fn main() { 4 | let v = vec![1, 2, 3]; 5 | 6 | let handle = thread::spawn(|| { 7 | println!("Here's a vector: {:?}", v); 8 | }); 9 | 10 | drop(v); // oh no! 11 | 12 | handle.join(); 13 | } -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_1/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut num = 5; 3 | 4 | let r1 = &num as *const i32; 5 | let r2 = &mut num as *mut i32; 6 | 7 | unsafe { 8 | println!("r1 is: {}", *r1); 9 | println!("r2 is: {}", *r2); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_10/src/main.rs: -------------------------------------------------------------------------------- 1 | struct Context(&str); 2 | 3 | struct Parser { 4 | context: &Context, 5 | } 6 | 7 | impl Parser { 8 | fn parse(&self) -> Result<(), &str> { 9 | Err(&self.context.0[1..]) 10 | } 11 | } 12 | 13 | fn main() { 14 | 15 | } -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_18/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | trait Foo {} 3 | 4 | struct Bar<'a> { 5 | pub x: &'a i32, 6 | } 7 | 8 | impl<'a> Foo for Bar<'a> {} 9 | 10 | let num = 5; 11 | 12 | let _obj = Box::new(Bar { x: &num }) as Box; 13 | } 14 | -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello10/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello! 6 | 7 | 8 |

Oops!

9 |

Sorry, I don't know what you're asking for.

10 | 11 | -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello11/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello! 6 | 7 | 8 |

Oops!

9 |

Sorry, I don't know what you're asking for.

10 | 11 | -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello12/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello! 6 | 7 | 8 |

Oops!

9 |

Sorry, I don't know what you're asking for.

10 | 11 | -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello13/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello! 6 | 7 | 8 |

Oops!

9 |

Sorry, I don't know what you're asking for.

10 | 11 | -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello14/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello! 6 | 7 | 8 |

Oops!

9 |

Sorry, I don't know what you're asking for.

10 | 11 | -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello15/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello! 6 | 7 | 8 |

Oops!

9 |

Sorry, I don't know what you're asking for.

10 | 11 | -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello16/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello! 6 | 7 | 8 |

Oops!

9 |

Sorry, I don't know what you're asking for.

10 | 11 | -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello17/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello! 6 | 7 | 8 |

Oops!

9 |

Sorry, I don't know what you're asking for.

10 | 11 | -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello18/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello! 6 | 7 | 8 |

Oops!

9 |

Sorry, I don't know what you're asking for.

10 | 11 | -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello19/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello! 6 | 7 | 8 |

Oops!

9 |

Sorry, I don't know what you're asking for.

10 | 11 | -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello20/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello! 6 | 7 | 8 |

Oops!

9 |

Sorry, I don't know what you're asking for.

10 | 11 | -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello21/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello! 6 | 7 | 8 |

Oops!

9 |

Sorry, I don't know what you're asking for.

10 | 11 | -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello4/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello! 6 | 7 | 8 |

Oops!

9 |

Sorry, I don't know what you're asking for.

10 | 11 | -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello5/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello! 6 | 7 | 8 |

Oops!

9 |

Sorry, I don't know what you're asking for.

10 | 11 | -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello6/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello! 6 | 7 | 8 |

Oops!

9 |

Sorry, I don't know what you're asking for.

10 | 11 | -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello7/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello! 6 | 7 | 8 |

Oops!

9 |

Sorry, I don't know what you're asking for.

10 | 11 | -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello8/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello! 6 | 7 | 8 |

Oops!

9 |

Sorry, I don't know what you're asking for.

10 | 11 | -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello9/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hello! 6 | 7 | 8 |

Oops!

9 |

Sorry, I don't know what you're asking for.

10 | 11 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_9/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let guess: 3 | //u8 4 | //u16 5 | //u32 6 | //u64 7 | i8 8 | //i16 9 | //i32 10 | //i64 11 | //isize 12 | //usize 13 | 14 | = "-42".parse().expect("Not a number!"); 15 | println!("guess = {}",guess); 16 | } -------------------------------------------------------------------------------- /second-edition/examples/ch14/adder/add-one/src/lib.rs: -------------------------------------------------------------------------------- 1 | extern crate rand; 2 | 3 | pub fn add_one(x: i32) -> i32 { 4 | x + 1 5 | } 6 | 7 | #[cfg(test)] 8 | mod tests { 9 | use super::*; 10 | 11 | #[test] 12 | fn it_works() { 13 | assert_eq!(3, add_one(2)); 14 | } 15 | } -------------------------------------------------------------------------------- /second-edition/examples/ch15/ch15_2/src/main.rs: -------------------------------------------------------------------------------- 1 | enum List { 2 | Cons(i32, Box), 3 | Nil, 4 | } 5 | 6 | use List::{Cons, Nil}; 7 | 8 | fn main() { 9 | let list = Cons(1, 10 | Box::new(Cons(2, 11 | Box::new(Cons(3, 12 | Box::new(Nil)))))); 13 | } -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_3/src/main.rs: -------------------------------------------------------------------------------- 1 | pub fn split_at_mut(slice: &mut [i32], mid: usize) -> (&mut [i32], &mut [i32]) { 2 | let len = slice.len(); 3 | 4 | assert!(mid <= len); 5 | 6 | (&mut slice[..mid], 7 | &mut slice[mid..]) 8 | } 9 | 10 | fn main() { 11 | 12 | } -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_19/src/main.rs: -------------------------------------------------------------------------------- 1 | struct Point { 2 | pub x: i32, 3 | pub y: i32, 4 | pub z: i32, 5 | } 6 | fn main() { 7 | let origin = Point { x: 0, y: 0, z: 0 }; 8 | 9 | match origin { 10 | Point { x, .. } => println!("x is {}", x), 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /second-edition/examples/ch12/minigrep1/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::env; 2 | 3 | fn main() { 4 | let args: Vec = env::args().collect(); 5 | 6 | let query = &args[1]; 7 | let filename = &args[2]; 8 | 9 | println!("Searching for {}", query); 10 | println!("In file {}", filename); 11 | } -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_8/src/main.rs: -------------------------------------------------------------------------------- 1 | static mut COUNTER: u32 = 0; 2 | 3 | fn add_to_count(inc: u32) { 4 | unsafe { 5 | COUNTER += inc; 6 | } 7 | } 8 | 9 | fn main() { 10 | add_to_count(3); 11 | 12 | unsafe { 13 | println!("COUNTER: {}", COUNTER); 14 | } 15 | } -------------------------------------------------------------------------------- /second-edition/examples/ch4/ch4_16/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let s = String::from("hello"); 3 | 4 | let len = s.len(); 5 | println!("sting length = {}", len); 6 | let slice = &s[3..len]; 7 | println!("{}", slice); 8 | let slice = &s[3..]; 9 | println!("{}", slice); 10 | } 11 | -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_22/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let robot_name = Some(String::from("Bors")); 3 | 4 | match robot_name { 5 | Some(name) => println!("Found a name: {}", name), 6 | None => (), 7 | } 8 | 9 | println!("robot_name is: {:?}", robot_name); 10 | } 11 | -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_23/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let robot_name = Some(String::from("Bors")); 3 | 4 | match robot_name { 5 | Some(ref name) => println!("Found a name: {}", name), 6 | None => (), 7 | } 8 | 9 | println!("robot_name is: {:?}", robot_name); 10 | } 11 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_32/src/main.rs: -------------------------------------------------------------------------------- 1 | fn add_one(x: i32) -> i32 { 2 | x + 1 3 | } 4 | 5 | fn do_twice(f: fn(i32) -> i32, arg: i32) -> i32 { 6 | f(arg) + f(arg) 7 | } 8 | 9 | fn main() { 10 | let answer = do_twice(add_one, 5); 11 | 12 | println!("The answer is: {}", answer); 13 | } 14 | -------------------------------------------------------------------------------- /second-edition/examples/ch7/ch7_1/src/main.rs: -------------------------------------------------------------------------------- 1 | pub mod a { 2 | pub mod series { 3 | pub mod of { 4 | pub fn nested_modules() { 5 | println!("nested_modules"); 6 | } 7 | } 8 | } 9 | } 10 | 11 | fn main() { 12 | a::series::of::nested_modules(); 13 | } -------------------------------------------------------------------------------- /second-edition/src/ch17-00-oop.md: -------------------------------------------------------------------------------- 1 | # Является ли Rust ООП языком программирования? 2 | 3 | ООП - концепция программирования для моделирования процессов и объектов. Существует 4 | множество определений ООП. Язык Rust нельзя однозначно отнести к языку ООП. Далее 5 | мы рассмотрим концепции ООП и как они реализуются в Rust. 6 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_11/src/main.rs: -------------------------------------------------------------------------------- 1 | pub struct Context<'a>(&'a str); 2 | 3 | pub struct Parser<'a> { 4 | pub context: &'a Context<'a>, 5 | } 6 | 7 | impl<'a> Parser<'a> { 8 | pub fn parse(&self) -> Result<(), &str> { 9 | Err(&self.context.0[1..]) 10 | } 11 | } 12 | 13 | fn main() {} 14 | -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_24/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let mut robot_name = Some(String::from("Bors")); 3 | 4 | match robot_name { 5 | Some(ref mut name) => *name = String::from("Another name"), 6 | None => (), 7 | } 8 | 9 | println!("robot_name is: {:?}", robot_name); 10 | } 11 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_10/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let max = ::max_value(); 3 | let mut value = ::min_value(); 4 | loop { 5 | value = value + 1; 6 | 7 | println!("value = {}", value); 8 | 9 | if value == max { 10 | break; 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /second-edition/examples/ch5/ch5_8/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let length1 = 50; 3 | let width1 = 30; 4 | 5 | println!( 6 | "The area of the rectangle is {} square pixels.", 7 | area(length1, width1) 8 | ); 9 | } 10 | 11 | fn area(length: u32, width: u32) -> u32 { 12 | length * width 13 | } -------------------------------------------------------------------------------- /second-edition/examples/ch15/ch15_7/src/main.rs: -------------------------------------------------------------------------------- 1 | enum List { 2 | Cons(i32, Rc), 3 | Nil, 4 | } 5 | 6 | use List::{Cons, Nil}; 7 | use std::rc::Rc; 8 | 9 | fn main() { 10 | let a = Rc::new(Cons(5, Rc::new(Cons(10, Rc::new(Nil))))); 11 | let _b = Cons(3, a.clone()); 12 | let _c = Cons(4, a.clone()); 13 | } -------------------------------------------------------------------------------- /second-edition/examples/ch15/ch15_6/src/main.rs: -------------------------------------------------------------------------------- 1 | enum List { 2 | Cons(i32, Box), 3 | Nil, 4 | } 5 | 6 | use List::{Cons, Nil}; 7 | 8 | fn main() { 9 | let a = Cons(5, 10 | Box::new(Cons(10, 11 | Box::new(Nil)))); 12 | let _b = Cons(3, Box::new(a)); 13 | let _c = Cons(4, Box::new(a)); 14 | } -------------------------------------------------------------------------------- /second-edition/examples/ch4/ch4_17/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let s = String::from("hello"); 3 | println!("{}", s); 4 | let len = s.len(); 5 | println!("a length of the string = {}", s); 6 | let slice = &s[0..len]; 7 | println!("{}", slice); 8 | let slice = &s[..]; 9 | println!("{}", slice); 10 | } 11 | -------------------------------------------------------------------------------- /second-edition/examples/ch7/ch7_2/src/main.rs: -------------------------------------------------------------------------------- 1 | pub mod a { 2 | pub mod series { 3 | pub mod of { 4 | pub fn nested_modules() { 5 | println!("nested_modules"); 6 | } 7 | } 8 | } 9 | } 10 | 11 | use a::series::of; 12 | 13 | fn main() { 14 | of::nested_modules(); 15 | } -------------------------------------------------------------------------------- /second-edition/examples/ch17/ch17_5/src/lib.rs: -------------------------------------------------------------------------------- 1 | extern crate rust_gui; 2 | use rust_gui::Draw; 3 | 4 | pub struct SelectBox { 5 | pub width: u32, 6 | pub height: u32, 7 | pub options: Vec, 8 | } 9 | 10 | impl Draw for SelectBox { 11 | fn draw(&self) { 12 | // Code to actually draw a select box 13 | } 14 | } -------------------------------------------------------------------------------- /second-edition/examples/ch7/ch7_3/src/main.rs: -------------------------------------------------------------------------------- 1 | pub mod a { 2 | pub mod series { 3 | pub mod of { 4 | pub fn nested_modules() { 5 | println!("nested_modules"); 6 | } 7 | } 8 | } 9 | } 10 | use a::series::of::nested_modules; 11 | 12 | fn main() { 13 | nested_modules(); 14 | } -------------------------------------------------------------------------------- /second-edition/examples/ch7/communicator/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod client; 2 | 3 | pub mod network; 4 | 5 | #[cfg(test)] 6 | mod tests { 7 | 8 | 9 | use super::client; 10 | 11 | #[test] 12 | fn it_works() { 13 | 14 | client::connect(); 15 | //::client::connect(); 16 | //super::client::connect(); 17 | } 18 | } -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch10_20/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x = 5; // -----+-- 'b 3 | //{ // | 4 | let r = &x; // --+--+-- 'a 5 | //} // | | 6 | println!("r: {}", r); // | | 7 | // --+ | 8 | } // -----+ 9 | -------------------------------------------------------------------------------- /second-edition/examples/ch16/ch16_1/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::thread; 2 | 3 | fn main() { 4 | thread::spawn(|| { 5 | for i in 1..10 { 6 | println!("hi number {} from the spawned thread!", i); 7 | } 8 | }); 9 | 10 | for i in 1..5 { 11 | println!("hi number {} from the main thread!", i); 12 | } 13 | } -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_30/src/main.rs: -------------------------------------------------------------------------------- 1 | type Thunk = Box; 2 | 3 | pub fn takes_long_type(_f: Thunk) { 4 | // ...snip... 5 | } 6 | 7 | pub fn returns_long_type() -> Thunk { 8 | // ...snip... 9 | Box::new(|| ()) 10 | } 11 | 12 | fn main() { 13 | let _f: Thunk = Box::new(|| println!("hi")); 14 | } -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_22/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::collections::HashMap; 2 | 3 | fn main() { 4 | let mut scores = HashMap::new(); 5 | 6 | scores.insert(String::from("Blue"), 10); 7 | scores.insert(String::from("Yellow"), 50); 8 | 9 | for (key, value) in &scores { 10 | println!("{}: {}", key, value); 11 | } 12 | } -------------------------------------------------------------------------------- /second-edition/examples/ch11/adder/tests/integration_test.rs: -------------------------------------------------------------------------------- 1 | extern crate adder; 2 | //cargo test --test integration_test 3 | #[test] 4 | fn integration_adds_two() { 5 | assert_eq!(4, adder::add_two(2)); 6 | } 7 | 8 | mod common; 9 | 10 | #[test] 11 | fn it_adds_two() { 12 | common::setup(); 13 | assert_eq!(4, adder::add_two(2)); 14 | } -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch10_weather_forecast/src/main.rs: -------------------------------------------------------------------------------- 1 | extern crate aggregator; 2 | 3 | fn main() { 4 | let weather_forecast = WeatherForecast { 5 | high_temp: 30., 6 | low_temp: -10., 7 | chance_of_precipitation: 25.5, 8 | 9 | }; 10 | 11 | println!("the weather in the forecast new is {}", weather_forecast.summary()); 12 | } 13 | -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch9/ch9_3/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::fs::File; 2 | 3 | fn main() { 4 | let f = File::open("hello.txt"); 5 | 6 | let f = match f { 7 | Ok(file) => file, 8 | Err(error) => { 9 | panic!("There was a problem opening the file: {:?}", error) 10 | }, 11 | }; 12 | println!("{:#?}",f); 13 | } -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_24/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::collections::HashMap; 2 | 3 | fn main() { 4 | let mut scores = HashMap::new(); 5 | scores.insert(String::from("Blue"), 10); 6 | 7 | scores.entry(String::from("Yellow")).or_insert(50); 8 | scores.entry(String::from("Blue")).or_insert(50); 9 | 10 | println!("{:?}", scores); 11 | } -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_29/src/main.rs: -------------------------------------------------------------------------------- 1 | pub fn takes_long_type(_f: Box) { 2 | // ...snip... 3 | } 4 | 5 | pub fn returns_long_type() -> Box { 6 | // ...snip... 7 | Box::new(|| ()) 8 | } 9 | 10 | fn main() { 11 | let _f: Box = Box::new(|| println!("hi")); 12 | } 13 | -------------------------------------------------------------------------------- /second-edition/examples/ch17/ch17_3/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub trait Draw { 2 | fn draw(&self); 3 | } 4 | pub struct Screen { 5 | pub components: Vec, 6 | } 7 | 8 | impl Screen 9 | where T: Draw { 10 | pub fn run(&self) { 11 | for component in self.components.iter() { 12 | component.draw(); 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /second-edition/examples/ch16/ch16_9/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::thread; 2 | use std::sync::mpsc; 3 | 4 | fn main() { 5 | let (tx, rx) = mpsc::channel(); 6 | 7 | thread::spawn(move || { 8 | let val = String::from("hi"); 9 | tx.send(val).unwrap(); 10 | }); 11 | 12 | let received = rx.recv().unwrap(); 13 | println!("Got: {}", received); 14 | } -------------------------------------------------------------------------------- /second-edition/examples/ch17/blog2/src/main.rs: -------------------------------------------------------------------------------- 1 | extern crate blog2; 2 | use blog2::Post; 3 | 4 | fn main() { 5 | let mut post = Post::new(); 6 | 7 | post.add_text("I ate a salad for lunch today"); 8 | 9 | let post = post.request_review(); 10 | 11 | let post = post.approve(); 12 | 13 | assert_eq!("I ate a salad for lunch today", post.content()); 14 | } -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_26/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x = Some(5); 3 | let y = 10; 4 | 5 | match x { 6 | Some(50) => println!("Got 50"), 7 | Some(n) if n == y => println!("Matched, n = {:?}", n), 8 | _ => println!("Default case, x = {:?}", x), 9 | } 10 | 11 | println!("at the end: x = {:?}, y = {:?}", x, y); 12 | } -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch9/ch9_9/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::io; 2 | use std::io::Read; 3 | use std::fs::File; 4 | 5 | fn read_username_from_file() -> Result { 6 | let mut s = String::new(); 7 | 8 | File::open("hello.txt")?.read_to_string(&mut s)?; 9 | 10 | Ok(s) 11 | } 12 | 13 | fn main(){ 14 | println!("{:#?}", read_username_from_file()); 15 | } -------------------------------------------------------------------------------- /second-edition/examples/ch4/ch4_4/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let s1 = String::from("hello"); 3 | 4 | let (s2, len) = calculate_length(s1); 5 | 6 | println!("The length of '{}' is {}.", s2, len); 7 | } 8 | 9 | fn calculate_length(s: String) -> (String, usize) { 10 | let length = s.len(); // len() returns the length of a String. 11 | 12 | (s, length) 13 | } -------------------------------------------------------------------------------- /second-edition/examples/ch7/ch7_6/src/main.rs: -------------------------------------------------------------------------------- 1 | #[derive(Debug)] 2 | enum TrafficLight { 3 | Red, 4 | Yellow, 5 | Green, 6 | } 7 | 8 | use TrafficLight::*; 9 | 10 | fn main() { 11 | let red = Red; 12 | let yellow = Yellow; 13 | let green = Green; 14 | 15 | println!("{:?}",red); 16 | println!("{:?}",yellow); 17 | println!("{:?}",green); 18 | } -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_25/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::collections::HashMap; 2 | 3 | fn main() { 4 | 5 | let text = "hello world wonderful world"; 6 | 7 | let mut map = HashMap::new(); 8 | 9 | for word in text.split_whitespace() { 10 | let count = map.entry(word).or_insert(0); 11 | *count += 1; 12 | } 13 | 14 | println!("{:?}", map); 15 | } -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | dist: trusty 3 | language: rust 4 | cache: cargo 5 | rust: 6 | - nightly 7 | branches: 8 | only: 9 | - master 10 | addons: 11 | apt: 12 | packages: 13 | - aspell 14 | - aspell-en 15 | before_script: 16 | - (cargo install mdbook --git https://github.com/azerupi/mdBook.git --force || true) 17 | script: 18 | - bash ci/build.sh 19 | -------------------------------------------------------------------------------- /second-edition/examples/ch16/ch16_2/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::thread; 2 | 3 | fn main() { 4 | let handle = thread::spawn(|| { 5 | for i in 1..10 { 6 | println!("hi number {} from the spawned thread!", i); 7 | } 8 | }); 9 | 10 | for i in 1..5 { 11 | println!("hi number {} from the main thread!", i); 12 | } 13 | 14 | handle.join(); 15 | } -------------------------------------------------------------------------------- /second-edition/examples/ch16/ch16_3/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::thread; 2 | 3 | fn main() { 4 | let handle = thread::spawn(|| { 5 | for i in 1..10 { 6 | println!("hi number {} from the spawned thread!", i); 7 | } 8 | }); 9 | 10 | handle.join(); 11 | 12 | for i in 1..5 { 13 | println!("hi number {} from the main thread!", i); 14 | } 15 | } -------------------------------------------------------------------------------- /second-edition/examples/ch6/ch6_2/src/main.rs: -------------------------------------------------------------------------------- 1 | pub enum Message { 2 | Quit, 3 | Move { x: i32, y: i32 }, 4 | Write(String), 5 | ChangeColor(i32, i32, i32), 6 | } 7 | 8 | impl Message { 9 | fn call(&self) { 10 | // method body would be defined here 11 | } 12 | } 13 | fn main() { 14 | let m = Message::Write(String::from("hello")); 15 | m.call(); 16 | } -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_19/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::collections::HashMap; 2 | 3 | fn main() { 4 | use std::collections::HashMap; 5 | 6 | let teams = vec![String::from("Blue"), String::from("Yellow")]; 7 | let initial_scores = vec![10, 50]; 8 | 9 | let scores: HashMap<_, _> = teams.iter().zip(initial_scores.iter()).collect(); 10 | println!("{:?}", scores); 11 | } -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_20/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::collections::HashMap; 2 | 3 | fn main() { 4 | let field_name = String::from("Favorite color"); 5 | let field_value = String::from("Blue"); 6 | 7 | let mut map = HashMap::new(); 8 | map.insert(field_name, field_value); 9 | // field_name and field_value are invalid at this point 10 | println!("{:?}", map); 11 | } -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_21/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::collections::HashMap; 2 | 3 | fn main() { 4 | let mut scores = HashMap::new(); 5 | 6 | scores.insert(String::from("Blue"), 10); 7 | scores.insert(String::from("Yellow"), 50); 8 | 9 | let team_name = String::from("Blue"); 10 | let score = scores.get(&team_name); 11 | println!("{} {:?}", team_name, score); 12 | } -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch10_22/src/main.rs: -------------------------------------------------------------------------------- 1 | fn longest(x: &str, y: &str) -> &str { 2 | if x.len() > y.len() { 3 | x 4 | } else { 5 | y 6 | } 7 | } 8 | 9 | fn main() { 10 | let string1 = String::from("abcd"); 11 | let string2 = "xyz"; 12 | 13 | let result = longest(string1.as_str(), string2); 14 | println!("The longest string is {}", result); 15 | } -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch10_6/src/main.rs: -------------------------------------------------------------------------------- 1 | struct Point { 2 | x: T, 3 | y: T, 4 | } 5 | 6 | impl Point { 7 | fn x(&self) -> &T { 8 | &self.x 9 | } 10 | } 11 | 12 | fn main() { 13 | let p1 = Point { x: 5, y: 10 }; 14 | let p2 = Point { x: p1.x, y: p1.y }; 15 | 16 | println!("p1.x() = {}", p1.x()); 17 | println!("p2.x = {}", p2.x()); 18 | } 19 | -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch9/ch9_8/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::io; 2 | use std::io::Read; 3 | use std::fs::File; 4 | 5 | fn read_username_from_file() -> Result { 6 | let mut f = File::open("hello.txt")?; 7 | let mut s = String::new(); 8 | f.read_to_string(&mut s)?; 9 | Ok(s) 10 | } 11 | fn main(){ 12 | 13 | println!("{:#?}", read_username_from_file()); 14 | 15 | } -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch10_26/src/main.rs: -------------------------------------------------------------------------------- 1 | struct ImportantExcerpt<'a> { 2 | part: &'a str, 3 | } 4 | 5 | fn main() { 6 | let novel = String::from("Call me Ishmael. Some years ago..."); 7 | let first_sentence = novel.split('.') 8 | .next() 9 | .expect("Could not find a '.'"); 10 | let i = ImportantExcerpt { part: first_sentence }; 11 | println!("{}",i.part); 12 | } -------------------------------------------------------------------------------- /second-edition/examples/ch7/ch7_4/src/main.rs: -------------------------------------------------------------------------------- 1 | #[derive(Debug)] 2 | enum TrafficLight { 3 | Red, 4 | Yellow, 5 | Green, 6 | } 7 | 8 | use TrafficLight::{Red, Yellow}; 9 | 10 | fn main() { 11 | let red = Red; 12 | let yellow = Yellow; 13 | let green = TrafficLight::Green; 14 | 15 | println!("{:?}",red); 16 | println!("{:?}",yellow); 17 | println!("{:?}",green); 18 | } -------------------------------------------------------------------------------- /second-edition/examples/ch7/ch7_5/src/main.rs: -------------------------------------------------------------------------------- 1 | #[derive(Debug)] 2 | enum TrafficLight { 3 | Red, 4 | Yellow, 5 | Green, 6 | } 7 | 8 | use TrafficLight::{Red, Yellow}; 9 | 10 | fn main() { 11 | let red = Red; 12 | let yellow = Yellow; 13 | let green = TrafficLight::Green; 14 | 15 | println!("{:?}",red); 16 | println!("{:?}",yellow); 17 | println!("{:?}",green); 18 | } -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_14/src/main.rs: -------------------------------------------------------------------------------- 1 | struct Point { 2 | x: i32, 3 | y: i32, 4 | } 5 | 6 | fn main() { 7 | let points = vec![ 8 | Point { x: 0, y: 0 }, 9 | Point { x: 1, y: 5 }, 10 | Point { x: 10, y: -3 }, 11 | ]; 12 | let sum_of_squares: i32 = points.iter().map(|&Point { x, y }| x * x + y * y).sum(); 13 | println!("{}", sum_of_squares); 14 | } 15 | -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_9/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x = 5; 3 | 4 | match x { 5 | 1...5 => println!("one through five"), 6 | _ => println!("something else"), 7 | } 8 | 9 | for x in 1..7 { 10 | match x { 11 | 1...5 => println!("`for` one through five"), 12 | _ => println!("something else"), 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_27/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::fmt; 2 | 3 | struct Wrapper(Vec); 4 | 5 | impl fmt::Display for Wrapper { 6 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 7 | write!(f, "[{}]", self.0.join(", ")) 8 | } 9 | } 10 | 11 | fn main() { 12 | let w = Wrapper(vec![String::from("hello"), String::from("world")]); 13 | println!("w = {}", w); 14 | } 15 | -------------------------------------------------------------------------------- /second-edition/examples/ch8/ch8_9/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | #[derive(Debug)] 3 | enum SpreadsheetCell { 4 | Int(i32), 5 | Float(f64), 6 | Text(String), 7 | } 8 | 9 | let row = vec![ 10 | SpreadsheetCell::Int(3), 11 | SpreadsheetCell::Text(String::from("blue")), 12 | SpreadsheetCell::Float(10.12), 13 | ]; 14 | println!("{:?}", row); 15 | } -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch10_23/src/main.rs: -------------------------------------------------------------------------------- 1 | 2 | fn longest<'a>(x: &'a str, y: &'a str) -> &'a str { 3 | if x.len() > y.len() { 4 | x 5 | } else { 6 | y 7 | } 8 | } 9 | 10 | fn main() { 11 | let string1 = String::from("abcd"); 12 | let string2 = "xyz"; 13 | 14 | let result = longest(string1.as_str(), string2); 15 | println!("The longest string is {}", result); 16 | } -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch10_25_1/src/main.rs: -------------------------------------------------------------------------------- 1 | fn longest<'a>(x: &'a str, _y: &str) -> &'a str { 2 | x 3 | } 4 | 5 | 6 | fn main() { 7 | let string1 = String::from("long string is long"); 8 | let result; 9 | { 10 | let string2 = String::from("xyz"); 11 | result = longest(string1.as_str(), string2.as_str()); 12 | } 13 | println!("The longest string is {}", result); 14 | } -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_25/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let months = [ 3 | "January", 4 | "February", 5 | "March", 6 | "April", 7 | "May", 8 | "June", 9 | "July", 10 | "August", 11 | "September", 12 | "October", 13 | "November", 14 | "December", 15 | ]; 16 | println!("a is: {:?}", months); 17 | } 18 | -------------------------------------------------------------------------------- /second-edition/examples/ch17/blog/src/main.rs: -------------------------------------------------------------------------------- 1 | extern crate blog; 2 | use blog::Post; 3 | 4 | fn main() { 5 | let mut post = Post::new(); 6 | 7 | post.add_text("I ate a salad for lunch today"); 8 | assert_eq!("", post.content()); 9 | 10 | post.request_review(); 11 | assert_eq!("", post.content()); 12 | 13 | post.approve(); 14 | assert_eq!("I ate a salad for lunch today", post.content()); 15 | } -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_13/src/main.rs: -------------------------------------------------------------------------------- 1 | 2 | struct Point { 3 | x: i32, 4 | y: i32, 5 | } 6 | 7 | fn main() { 8 | let p = Point { x: 0, y: 7 }; 9 | 10 | match p { 11 | Point { x, y: 0 } => println!("On the x axis at {}", x), 12 | Point { x: 0, y } => println!("On the y axis at {}", y), 13 | Point { x, y } => println!("On neither axis: ({}, {})", x, y), 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch10_4/src/main.rs: -------------------------------------------------------------------------------- 1 | #[derive(Debug)] 2 | struct Point { 3 | x: T, 4 | y: T, 5 | } 6 | 7 | fn main() { 8 | /* 9 | let integer = Point { x: 5, y: 10 }; 10 | let float = Point { x: 1.0, y: 4.0 }; 11 | println!("{:?}", integer); 12 | println!("{:?}", float); 13 | 14 | */ 15 | 16 | let wont_work = Point { x: 5., y: 4.0 }; 17 | println!("{:?}", wont_work); 18 | } 19 | -------------------------------------------------------------------------------- /second-edition/examples/ch12/minigrep/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::env; 2 | 3 | 4 | fn main() { 5 | //let args: Vec = env::args().collect(); 6 | //println!("{:?}", args); 7 | 8 | //println!("{:#?}", env::args()); 9 | 10 | //let args: Vec = env::args_os().collect(); 11 | //let args = env::args_os().collect(); 12 | //let args: _ = env::args_os().collect(); 13 | println!("{:?}", args); 14 | } -------------------------------------------------------------------------------- /second-edition/examples/ch18/ch18_7/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let x = Some(3); 3 | let y = 10; 4 | 5 | match x { 6 | Some(50) => println!("Got 50"), 7 | //Some(y) => println!("Matched, y = {:?}", y), 8 | Some(z) => println!("Matched, z = {:?}", z), 9 | _ => println!("Default case, x = {:?}", x), 10 | } 11 | 12 | println!("at the end: x = {:?}, y = {:?}", x, y); 13 | } 14 | -------------------------------------------------------------------------------- /second-edition/examples/ch20/hello/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::net::TcpListener; 2 | 3 | fn main() { 4 | let listener = TcpListener::bind("127.0.0.1:8080").unwrap(); 5 | 6 | //let mut i: u32 = 0; 7 | for stream in listener.incoming() { 8 | let _stream = stream.unwrap(); 9 | // i = i + 1; 10 | // println!("Connection {} established!", i); 11 | println!("Connection established!"); 12 | } 13 | } -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_11/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let value = 98_222_000; 3 | println!("value = {}", value); 4 | 5 | let value = 0xff; 6 | println!("value = {}", value); 7 | 8 | let value = 0o77; 9 | println!("value = {}", value); 10 | 11 | let value = 0b1111_0000; 12 | println!("value = {}", value); 13 | 14 | let value = b'A'; 15 | println!("value = {}", value); 16 | } 17 | -------------------------------------------------------------------------------- /first-edition/src/effective-rust.md: -------------------------------------------------------------------------------- 1 | # Effective Rust 2 | 3 | So you’ve learned how to write some Rust code. But there’s a difference between 4 | writing *any* Rust code and writing *good* Rust code. 5 | 6 | This chapter consists of relatively independent tutorials which show you how to 7 | take your Rust to the next level. Common patterns and standard library features 8 | will be introduced. Read these sections in any order of your choosing. 9 | -------------------------------------------------------------------------------- /second-edition/examples/ch15/ch15_4/src/main.rs: -------------------------------------------------------------------------------- 1 | struct CustomSmartPointer { 2 | pub data: String, 3 | } 4 | 5 | impl Drop for CustomSmartPointer { 6 | fn drop(&mut self) { 7 | println!("Dropping CustomSmartPointer!"); 8 | } 9 | } 10 | 11 | fn main() { 12 | let _c = CustomSmartPointer { data: String::from("some data") }; 13 | println!("CustomSmartPointer created."); 14 | println!("Wait for it..."); 15 | } -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_13/src/main.rs: -------------------------------------------------------------------------------- 1 | struct Context<'s>(&'s str); 2 | 3 | struct Parser<'c, 's> { 4 | context: &'c Context<'s>, 5 | } 6 | 7 | impl<'c, 's> Parser<'c, 's> { 8 | fn parse(&self) -> Result<(), &'s str> { 9 | Err(&self.context.0[1..]) 10 | } 11 | } 12 | 13 | fn parse_context(context: Context) -> Result<(), &str> { 14 | Parser { context: &context }.parse() 15 | } 16 | 17 | fn main() {} 18 | -------------------------------------------------------------------------------- /second-edition/examples/ch5/ch5_7_1/src/main.rs: -------------------------------------------------------------------------------- 1 | #[derive(Debug)] 2 | struct User<'a> { 3 | username: &'a str, 4 | email: &'a str, 5 | sign_in_count: u64, 6 | active: bool, 7 | } 8 | 9 | fn main() { 10 | let user1 = User { 11 | email: "someone@example.com", 12 | username: "someusername123", 13 | active: true, 14 | sign_in_count: 1, 15 | }; 16 | println!("{:?}",user1); 17 | } 18 | -------------------------------------------------------------------------------- /first-edition/src/syntax-and-semantics.md: -------------------------------------------------------------------------------- 1 | # Syntax and Semantics 2 | 3 | This chapter breaks Rust down into small chunks, one for each concept. 4 | 5 | If you’d like to learn Rust from the bottom up, reading this in order is a 6 | great way to do that. 7 | 8 | These sections also form a reference for each concept, so if you’re reading 9 | another tutorial and find something confusing, you can find it explained 10 | somewhere in here. 11 | -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch10_5/src/main.rs: -------------------------------------------------------------------------------- 1 | #[derive(Debug)] 2 | struct Point { 3 | x: T, 4 | y: U, 5 | } 6 | 7 | fn main() { 8 | let both_integer = Point { x: 5, y: 10 }; 9 | let both_float = Point { x: 1.0, y: 4.0 }; 10 | let integer_and_float = Point { x: 5, y: 4.0 }; 11 | 12 | println!("{:?}", both_integer); 13 | println!("{:?}", both_float); 14 | println!("{:?}", integer_and_float); 15 | } 16 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_12/src/main.rs: -------------------------------------------------------------------------------- 1 | pub struct Context<'a>(&'a str); 2 | 3 | pub struct Parser<'a> { 4 | pub context: &'a Context<'a>, 5 | } 6 | 7 | impl<'a> Parser<'a> { 8 | pub fn parse(&self) -> Result<(), &str> { 9 | Err(&self.context.0[1..]) 10 | } 11 | } 12 | 13 | fn parse_context(context: Context) -> Result<(), &str> { 14 | Parser { context: &context }.parse() 15 | } 16 | 17 | fn main() {} 18 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_15/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let value32_min = std::f32::MIN; 3 | println!("value f32 min = {}", value32_min); 4 | let value32_max = std::f32::MAX; 5 | println!("value f32 max = {}", value32_max); 6 | 7 | let value64_min = std::f64::MIN; 8 | println!("value f64 min = {}", value64_min); 9 | let value64_max = std::f64::MAX; 10 | println!("value f64 max = {}", value64_max); 11 | } 12 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_4/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::slice; 2 | 3 | pub fn split_at_mut(slice: &mut [i32], mid: usize) -> (&mut [i32], &mut [i32]) { 4 | let len = slice.len(); 5 | let ptr = slice.as_mut_ptr(); 6 | 7 | assert!(mid <= len); 8 | 9 | unsafe { 10 | (slice::from_raw_parts_mut(ptr, mid), 11 | slice::from_raw_parts_mut(ptr.offset(mid as isize), len - mid)) 12 | } 13 | } 14 | 15 | fn main() { 16 | 17 | } -------------------------------------------------------------------------------- /second-edition/examples/ch5/ch5_9/src/main.rs: -------------------------------------------------------------------------------- 1 | struct Rectangle { 2 | length: u32, 3 | width: u32, 4 | } 5 | 6 | fn main() { 7 | let rect1 = Rectangle { 8 | length: 50, 9 | width: 30, 10 | }; 11 | 12 | println!( 13 | "The area of the rectangle is {} square pixels.", 14 | area(&rect1) 15 | ); 16 | } 17 | 18 | fn area(rectangle: &Rectangle) -> u32 { 19 | rectangle.length * rectangle.width 20 | } 21 | -------------------------------------------------------------------------------- /second-edition/examples/ch19/ch19_14/src/main.rs: -------------------------------------------------------------------------------- 1 | pub struct Context<'s>(&'s str); 2 | 3 | pub struct Parser<'c, 's: 'c> { 4 | pub context: &'c Context<'s>, 5 | } 6 | 7 | impl<'c, 's> Parser<'c, 's> { 8 | pub fn parse(&self) -> Result<(), &'s str> { 9 | Err(&self.context.0[1..]) 10 | } 11 | } 12 | 13 | pub fn parse_context(context: Context) -> Result<(), &str> { 14 | Parser { context: &context }.parse() 15 | } 16 | 17 | fn main() {} 18 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_14/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let value = 9223372036854775807; 3 | //let value:i64 = 9223372036854775807; 4 | println!("value = {}", value); 5 | 6 | let value = -9223372036854775808; 7 | //let value:i64 = -9223372036854775808; 8 | println!("value = {}", value); 9 | 10 | let value = 18446744073709551615; 11 | //let value:u64 = 18446744073709551615; 12 | println!("value = {}", value); 13 | } 14 | -------------------------------------------------------------------------------- /second-edition/examples/ch3/ch3_16/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | let value = 9223372036854775807; 3 | //let value:i64 = 9223372036854775807; 4 | println!("value = {}", value); 5 | 6 | let value = -9223372036854775808; 7 | //let value:i64 = -9223372036854775808; 8 | println!("value = {}", value); 9 | 10 | let value = 18446744073709551615; 11 | //let value:u64 = 18446744073709551615; 12 | println!("value = {}", value); 13 | } 14 | -------------------------------------------------------------------------------- /second-edition/examples/ch5/ch5_1/src/main.rs: -------------------------------------------------------------------------------- 1 | #[derive(Debug)] 2 | struct User { 3 | username: String, 4 | email: String, 5 | sign_in_count: u64, 6 | active: bool, 7 | } 8 | 9 | 10 | fn main() { 11 | let user1 = User { 12 | email: String::from("someone@example.com"), 13 | username: String::from("someusername123"), 14 | active: true, 15 | sign_in_count: 1, 16 | }; 17 | println!("{:?}",user1); 18 | } 19 | -------------------------------------------------------------------------------- /second-edition/examples/ch5/ch5_10/src/main.rs: -------------------------------------------------------------------------------- 1 | struct Rectangle { 2 | length: u32, 3 | width: u32, 4 | } 5 | 6 | fn main() { 7 | let rect1 = &(Rectangle { 8 | length: 50, 9 | width: 30, 10 | }); 11 | 12 | println!( 13 | "The area of the rectangle is {} square pixels.", 14 | area(rect1) 15 | ); 16 | } 17 | 18 | fn area(rectangle: &Rectangle) -> u32 { 19 | rectangle.length * rectangle.width 20 | } 21 | -------------------------------------------------------------------------------- /redirects/if.md: -------------------------------------------------------------------------------- 1 | % There is a new edition of the book 2 | 3 | This is an old link. You can [continue to the exact older page][1]. 4 | If you're trying to learn Rust, checking out [the second edition][2] might be a better choice. 5 | 6 | * [This page in the first edition of the The Rust Programming Language][1] 7 | 8 | * [Index of the second edition of The Rust Programming Language][2] 9 | 10 | 11 | [1]: first-edition/if.html 12 | [2]: second-edition/index.html 13 | -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch10_27_2/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::fmt::Display; 2 | 3 | fn longest_with_an_announcement<'a, T>(x: &'a str, y: &'a str, ann: T) -> &'a str 4 | where T: Display 5 | { 6 | println!("Announcement! {}", ann); 7 | if x.len() > y.len() { 8 | x 9 | } else { 10 | y 11 | } 12 | } 13 | fn main() { 14 | 15 | let s = longest_with_an_announcement("text1","text2", 2); 16 | 17 | println!("{}", s); 18 | 19 | } 20 | -------------------------------------------------------------------------------- /redirects/drop.md: -------------------------------------------------------------------------------- 1 | % There is a new edition of the book 2 | 3 | This is an old link. You can [continue to the exact older page][1]. 4 | If you're trying to learn Rust, checking out [the second edition][2] might be a better choice. 5 | 6 | * [This page in the first edition of the The Rust Programming Language][1] 7 | 8 | * [Index of the second edition of The Rust Programming Language][2] 9 | 10 | 11 | [1]: first-edition/drop.html 12 | [2]: second-edition/index.html 13 | -------------------------------------------------------------------------------- /redirects/enums.md: -------------------------------------------------------------------------------- 1 | % There is a new edition of the book 2 | 3 | This is an old link. You can [continue to the exact older page][1]. 4 | If you're trying to learn Rust, checking out [the second edition][2] might be a better choice. 5 | 6 | * [This page in the first edition of the The Rust Programming Language][1] 7 | 8 | * [Index of the second edition of The Rust Programming Language][2] 9 | 10 | 11 | [1]: first-edition/enums.html 12 | [2]: second-edition/index.html 13 | -------------------------------------------------------------------------------- /redirects/ffi.md: -------------------------------------------------------------------------------- 1 | % There is a new edition of the book 2 | 3 | This is an old link. You can [continue to the exact older page][1]. 4 | If you're trying to learn Rust, checking out [the second edition][2] might be a better choice. 5 | 6 | * [This page in the first edition of the The Rust Programming Language][1] 7 | 8 | * [Index of the second edition of The Rust Programming Language][2] 9 | 10 | 11 | [1]: first-edition/ffi.html 12 | [2]: second-edition/index.html 13 | -------------------------------------------------------------------------------- /redirects/loops.md: -------------------------------------------------------------------------------- 1 | % There is a new edition of the book 2 | 3 | This is an old link. You can [continue to the exact older page][1]. 4 | If you're trying to learn Rust, checking out [the second edition][2] might be a better choice. 5 | 6 | * [This page in the first edition of the The Rust Programming Language][1] 7 | 8 | * [Index of the second edition of The Rust Programming Language][2] 9 | 10 | 11 | [1]: first-edition/loops.html 12 | [2]: second-edition/index.html 13 | -------------------------------------------------------------------------------- /redirects/match.md: -------------------------------------------------------------------------------- 1 | % There is a new edition of the book 2 | 3 | This is an old link. You can [continue to the exact older page][1]. 4 | If you're trying to learn Rust, checking out [the second edition][2] might be a better choice. 5 | 6 | * [This page in the first edition of the The Rust Programming Language][1] 7 | 8 | * [Index of the second edition of The Rust Programming Language][2] 9 | 10 | 11 | [1]: first-edition/match.html 12 | [2]: second-edition/index.html 13 | -------------------------------------------------------------------------------- /redirects/ufcs.md: -------------------------------------------------------------------------------- 1 | % There is a new edition of the book 2 | 3 | This is an old link. You can [continue to the exact older page][1]. 4 | If you're trying to learn Rust, checking out [the second edition][2] might be a better choice. 5 | 6 | * [This page in the first edition of the The Rust Programming Language][1] 7 | 8 | * [Index of the second edition of The Rust Programming Language][2] 9 | 10 | 11 | [1]: first-edition/ufcs.html 12 | [2]: second-edition/index.html 13 | -------------------------------------------------------------------------------- /second-edition/examples/ch15/ch15_6_1/src/main.rs: -------------------------------------------------------------------------------- 1 | use std::cell::RefCell; 2 | use std::rc::Rc; 3 | 4 | #[derive(Debug)] 5 | pub enum List { 6 | Cons(i32, RefCell>), 7 | Nil, 8 | } 9 | 10 | use List::{Cons, Nil}; 11 | 12 | impl List { 13 | pub fn tail(&self) -> Option<&RefCell>> { 14 | match *self { 15 | Cons(_, ref item) => Some(item), 16 | Nil => None, 17 | } 18 | } 19 | } 20 | 21 | fn main(){} -------------------------------------------------------------------------------- /redirects/if-let.md: -------------------------------------------------------------------------------- 1 | % There is a new edition of the book 2 | 3 | This is an old link. You can [continue to the exact older page][1]. 4 | If you're trying to learn Rust, checking out [the second edition][2] might be a better choice. 5 | 6 | * [This page in the first edition of the The Rust Programming Language][1] 7 | 8 | * [Index of the second edition of The Rust Programming Language][2] 9 | 10 | 11 | [1]: first-edition/if-let.html 12 | [2]: second-edition/index.html 13 | -------------------------------------------------------------------------------- /redirects/macros.md: -------------------------------------------------------------------------------- 1 | % There is a new edition of the book 2 | 3 | This is an old link. You can [continue to the exact older page][1]. 4 | If you're trying to learn Rust, checking out [the second edition][2] might be a better choice. 5 | 6 | * [This page in the first edition of the The Rust Programming Language][1] 7 | 8 | * [Index of the second edition of The Rust Programming Language][2] 9 | 10 | 11 | [1]: first-edition/macros.html 12 | [2]: second-edition/index.html 13 | -------------------------------------------------------------------------------- /redirects/strings.md: -------------------------------------------------------------------------------- 1 | % There is a new edition of the book 2 | 3 | This is an old link. You can [continue to the exact older page][1]. 4 | If you're trying to learn Rust, checking out [the second edition][2] might be a better choice. 5 | 6 | * [This page in the first edition of the The Rust Programming Language][1] 7 | 8 | * [Index of the second edition of The Rust Programming Language][2] 9 | 10 | 11 | [1]: first-edition/strings.html 12 | [2]: second-edition/index.html 13 | -------------------------------------------------------------------------------- /redirects/structs.md: -------------------------------------------------------------------------------- 1 | % There is a new edition of the book 2 | 3 | This is an old link. You can [continue to the exact older page][1]. 4 | If you're trying to learn Rust, checking out [the second edition][2] might be a better choice. 5 | 6 | * [This page in the first edition of the The Rust Programming Language][1] 7 | 8 | * [Index of the second edition of The Rust Programming Language][2] 9 | 10 | 11 | [1]: first-edition/structs.html 12 | [2]: second-edition/index.html 13 | -------------------------------------------------------------------------------- /redirects/testing.md: -------------------------------------------------------------------------------- 1 | % There is a new edition of the book 2 | 3 | This is an old link. You can [continue to the exact older page][1]. 4 | If you're trying to learn Rust, checking out [the second edition][2] might be a better choice. 5 | 6 | * [This page in the first edition of the The Rust Programming Language][1] 7 | 8 | * [Index of the second edition of The Rust Programming Language][2] 9 | 10 | 11 | [1]: first-edition/testing.html 12 | [2]: second-edition/index.html 13 | -------------------------------------------------------------------------------- /redirects/traits.md: -------------------------------------------------------------------------------- 1 | % There is a new edition of the book 2 | 3 | This is an old link. You can [continue to the exact older page][1]. 4 | If you're trying to learn Rust, checking out [the second edition][2] might be a better choice. 5 | 6 | * [This page in the first edition of the The Rust Programming Language][1] 7 | 8 | * [Index of the second edition of The Rust Programming Language][2] 9 | 10 | 11 | [1]: first-edition/traits.html 12 | [2]: second-edition/index.html 13 | -------------------------------------------------------------------------------- /redirects/unsafe.md: -------------------------------------------------------------------------------- 1 | % There is a new edition of the book 2 | 3 | This is an old link. You can [continue to the exact older page][1]. 4 | If you're trying to learn Rust, checking out [the second edition][2] might be a better choice. 5 | 6 | * [This page in the first edition of the The Rust Programming Language][1] 7 | 8 | * [Index of the second edition of The Rust Programming Language][2] 9 | 10 | 11 | [1]: first-edition/unsafe.html 12 | [2]: second-edition/index.html 13 | -------------------------------------------------------------------------------- /redirects/vectors.md: -------------------------------------------------------------------------------- 1 | % There is a new edition of the book 2 | 3 | This is an old link. You can [continue to the exact older page][1]. 4 | If you're trying to learn Rust, checking out [the second edition][2] might be a better choice. 5 | 6 | * [This page in the first edition of the The Rust Programming Language][1] 7 | 8 | * [Index of the second edition of The Rust Programming Language][2] 9 | 10 | 11 | [1]: first-edition/vectors.html 12 | [2]: second-edition/index.html 13 | -------------------------------------------------------------------------------- /second-edition/examples/ch10/ch10_25_2/src/main.rs: -------------------------------------------------------------------------------- 1 | fn longest<'a>(_x: &str, _y: &str) -> &'a str { 2 | let result = String::from("really long string"); 3 | result.as_str() 4 | } 5 | 6 | fn main() { 7 | let string1 = String::from("long string is long"); 8 | let result; 9 | { 10 | let string2 = String::from("xyz"); 11 | result = longest(string1.as_str(), string2.as_str()); 12 | } 13 | println!("The longest string is {}", result); 14 | } --------------------------------------------------------------------------------