Compare commits

...

14 Commits

Author SHA1 Message Date
Sunface 31c6314cf9
Merge pull request #378 from pawelgrzybek/master
Fix typo (add_tow ➡️ add_two)
2023-03-14 08:40:40 +08:00
Pawel Grzybek 311e2486eb
Fix typo
From add_tow to add_two
2023-03-10 10:14:42 +00:00
Sunface d86e8de385
Merge pull request #376 from delta549/issue_375
Added proposed change to variables shadowing problem 6
2023-03-09 09:22:54 +08:00
delta549 0d7d44258e Added proposed change to variables shadowing problem 6 2023-03-04 13:38:02 +00:00
Sunface 0d14bb3d1b
Merge pull request #362 from sunface/dependabot/cargo/zh-CN/assets/mini-redis/tokio-1.18.5
build(deps): bump tokio from 1.8.1 to 1.18.5 in /zh-CN/assets/mini-redis
2023-02-24 09:09:31 +08:00
Sunface 36c49b4ed2
Merge pull request #371 from QIN2DIM/master
fix: zh-CN typo `pracitce.rs`
2023-02-24 09:09:14 +08:00
QIN2DIM de0daef3ce
fix: zh-CN typo `pracitce.rs` 2023-02-21 22:55:55 +08:00
Sunface dbd9c9eff6
Merge pull request #360 from mayorcoded/patch-1
Update link to resource 2 (Building a text editor)
2023-02-13 10:51:20 +08:00
Sunface d75000d198
Merge pull request #358 from teddywaweru/patch-1
Update ownershp.md
2023-02-13 10:50:37 +08:00
Sunface 29ec34ef1f
Merge pull request #356 from Ziqi-Yang/ziqi-yang/link_solution
feat: add link_solution script
2023-02-13 10:49:37 +08:00
dependabot[bot] 6a981ecd94
build(deps): bump tokio from 1.8.1 to 1.18.5 in /zh-CN/assets/mini-redis
Bumps [tokio](https://github.com/tokio-rs/tokio) from 1.8.1 to 1.18.5.
- [Release notes](https://github.com/tokio-rs/tokio/releases)
- [Commits](https://github.com/tokio-rs/tokio/compare/tokio-1.8.1...tokio-1.18.5)

---
updated-dependencies:
- dependency-name: tokio
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-02-04 02:36:27 +00:00
Mayowa Tudonu 9d52cd5a7a
Update link to resource 2 (Building a text editor) 2023-02-02 15:06:50 +01:00
Teddy Waweru 65ab75f7d9
Update ownershp.md
Added as_str() method to Q1, & removed answer that did not seem relevant to the question.
2023-01-27 23:58:29 +03:00
Zarkli Leonardo 2d569b5a0b feat: add link_solution script
the script has the two functions:
  1. Link solution page to each practice page where there is no
     solution link.
  2. Correct solution link address (i.e. non-corresponding address).
2023-01-20 20:22:35 +08:00
7 changed files with 165 additions and 57 deletions

View File

@ -131,7 +131,7 @@ Then run `cargo doc --open` and see the results.
### Doc tests
The doc comments of `add_one` and `add_tow` contain two example code blocks.
The doc comments of `add_one` and `add_two` contain two example code blocks.
The examples can not only demonstrate how to use your library, but also running as test with `cargo test` command.

View File

@ -15,7 +15,7 @@ This is precisely the goal of this book, so, collecting relative resourses and r
Answers for above questions usually came with [`ripgrep`](https://github.com/BurntSushi/ripgrep), though I don't think it is a **small** project, but yes, go for it if you are not afraid to delve deep a bit.
### 2. Building a text editor
Tutorial [`https://www.philippflenker.com/hecto/`](https://www.philippflenker.com/hecto/) will lead you to build a text editor from scratch.
Tutorial [`https://www.flenker.blog/hecto/`](https://www.flenker.blog/hecto/) will lead you to build a text editor from scratch.
### 3. Ncspot
[Ncspot](https://github.com/hrkfdn/ncspot), a terminal Spotify client. Small, simple, well organized and async, it's good for learning.

44
scripts/link_solution Executable file
View File

@ -0,0 +1,44 @@
#!/usr/bin/env bash
#
# Function:
# 1. Link solution page to each practice page where there is no solution link
# 2. Correct link address (i.e. non-corresponding address)
#
# Usage:
# locate in the project root directory and execute the file
#
# Tips:
# Use 'git diff' to show the change after executing this command
set -e # exit on error
SOLUTION_DIR="solutions"
ZH_DIR="zh-CN/src"
EN_DIR="en/src"
LINK_PREFIX="https://github.com/sunface/rust-by-practice/blob/master"
# create an array of the relative address of all markdown file about practice in both Chinese and English
read -ra markdown_files <<< "$(echo "${ZH_DIR}"/**/*.md "${EN_DIR}"/**/*.md)"
for mdfile in "${markdown_files[@]}"; do
# if the corresponding solution file exist, check whether the practice file contians a
# link to solution or not. If not, create a link
solution_file=$( sed "s#\(${ZH_DIR}\|${EN_DIR}\)#${SOLUTION_DIR}#g" <<< "${mdfile}" )
if [[ -f "${solution_file}" ]]; then # exist solution file
echo -n "${mdfile}"
correct_link="${LINK_PREFIX}/${solution_file}"
found=$(grep -Ei '^\s*>.*https://.*solution.*$' < "${mdfile}" || true)
if [[ -z "${found}" ]]; then # not found link
echo >> "${mdfile}" # some file ends without newline character
if [[ "${mdfile}" == "${ZH_DIR}"/* ]]; then # written in Chinese
echo "> 你可以在[这里](${correct_link})找到答案(在 solutions 路径下)" >> "${mdfile}"
elif [[ "${mdfile}" == "${EN_DIR}"/* ]]; then # written in English
echo "> You can find the solutions [here](${correct_link})(under the solutions path), but only use it when you need it :)" >> "${mdfile}"
fi
else # found link in file
# simply correct all matched links
sed -i 's#^\(.*\)>\(.*\)(https://[^)]*)\(.*\)solution\(.*\)$#\1>\2('"${correct_link}"')\3solution\4#' "${mdfile}"
fi
echo " --done"
fi
done

View File

@ -23,11 +23,10 @@ fn main() {
println!("{},{}",x,y);
}
```
```rust
fn main() {
let x = 10;
let y = x;
let x = String::from("hello, world");
let y = x.as_str();
println!("{},{}",x,y);
}
```

View File

@ -83,8 +83,7 @@ fn main() {
let mut x: i32 = 1;
x = 7;
// Shadowing and re-binding
let mut x = x;
x += 3;
let x = x;
let y = 4;

View File

@ -136,15 +136,6 @@ dependencies = [
"libc",
]
[[package]]
name = "instant"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bee0328b1209d157ef001c94dd85b4f8f64139adb0eac2659f4b08382b2f474d"
dependencies = [
"cfg-if",
]
[[package]]
name = "itoa"
version = "0.4.7"
@ -159,15 +150,15 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "libc"
version = "0.2.98"
version = "0.2.139"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "320cfe77175da3a483efed4bc0adc1968ca050b098ce4f2f1c13a56626128790"
checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79"
[[package]]
name = "lock_api"
version = "0.4.4"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0382880606dff6d15c9476c416d18690b72742aa7b605bb6dd6ec9030fbf07eb"
checksum = "88943dd7ef4a2e5a4bfa2753aaab3013e34ce2533d1996fb18ef591e315e2b3b"
dependencies = [
"scopeguard",
]
@ -213,33 +204,14 @@ dependencies = [
[[package]]
name = "mio"
version = "0.7.13"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c2bdb6314ec10835cd3293dd268473a835c02b7b352e788be788b3c6ca6bb16"
checksum = "e5d732bc30207a6423068df043e3d02e0735b155ad7ce1a6f76fe2baa5b158de"
dependencies = [
"libc",
"log",
"miow",
"ntapi",
"winapi",
]
[[package]]
name = "miow"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21"
dependencies = [
"winapi",
]
[[package]]
name = "ntapi"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44"
dependencies = [
"winapi",
"wasi",
"windows-sys 0.42.0",
]
[[package]]
@ -279,27 +251,25 @@ checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56"
[[package]]
name = "parking_lot"
version = "0.11.1"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb"
checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f"
dependencies = [
"instant",
"lock_api",
"parking_lot_core",
]
[[package]]
name = "parking_lot_core"
version = "0.8.3"
version = "0.9.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018"
checksum = "9069cbb9f99e3a5083476ccb29ceb1de18b9118cafa53e90c9551235de2b9521"
dependencies = [
"cfg-if",
"instant",
"libc",
"redox_syscall",
"smallvec",
"winapi",
"windows-sys 0.45.0",
]
[[package]]
@ -456,6 +426,16 @@ version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e"
[[package]]
name = "socket2"
version = "0.4.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd"
dependencies = [
"libc",
"winapi",
]
[[package]]
name = "strsim"
version = "0.8.0"
@ -517,29 +497,28 @@ dependencies = [
[[package]]
name = "tokio"
version = "1.8.1"
version = "1.18.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "98c8b05dc14c75ea83d63dd391100353789f5f24b8b3866542a5e85c8be8e985"
checksum = "0e050c618355082ae5a89ec63bbf897225d5ffe84c7c4e036874e4d185a5044e"
dependencies = [
"autocfg",
"bytes",
"libc",
"memchr",
"mio",
"num_cpus",
"once_cell",
"parking_lot",
"pin-project-lite",
"signal-hook-registry",
"socket2",
"tokio-macros",
"winapi",
]
[[package]]
name = "tokio-macros"
version = "1.3.0"
version = "1.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "54473be61f4ebe4efd09cec9bd5d16fa51d70ea0192213d754d2d500457db110"
checksum = "d266c00fde287f55d3f1c3e96c500c362a2b8c695076ec180f27918820bc6df8"
dependencies = [
"proc-macro2",
"quote",
@ -672,6 +651,12 @@ version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe"
[[package]]
name = "wasi"
version = "0.11.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "winapi"
version = "0.3.9"
@ -693,3 +678,84 @@ name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows-sys"
version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
]
[[package]]
name = "windows-sys"
version = "0.45.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0"
dependencies = [
"windows-targets",
]
[[package]]
name = "windows-targets"
version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e2522491fbfcd58cc84d47aeb2958948c4b8982e9a2d8a2a35bbaed431390e7"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608"
[[package]]
name = "windows_aarch64_msvc"
version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7"
[[package]]
name = "windows_i686_gnu"
version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640"
[[package]]
name = "windows_i686_msvc"
version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605"
[[package]]
name = "windows_x86_64_gnu"
version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463"
[[package]]
name = "windows_x86_64_msvc"
version = "0.42.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd"

View File

@ -1,6 +1,6 @@
# Summary
- [关于 pracitce.rs](why-exercise.md)
- [关于 practice.rs](why-exercise.md)
- [值得学习的小型项目](elegant-code-base.md)
- [变量绑定与解构](variables.md)
- [基本类型](basic-types/intro.md)