From f15bccde2986b00f85b25a79c186441a0c522f43 Mon Sep 17 00:00:00 2001 From: sunface Date: Wed, 23 Feb 2022 15:14:41 +0800 Subject: [PATCH] add chinese zh repo --- .DS_Store | Bin 0 -> 6148 bytes .gitignore => en/.gitignore | 0 {assets => en/assets}/CNAME | 0 book.toml => en/book.toml | 8 +- deploy => en/deploy | 0 {src => en/src}/SUMMARY.md | 0 {src => en/src}/async/async-await.md | 0 {src => en/src}/async/future.md | 0 {src => en/src}/async/intro.md | 0 {src => en/src}/async/pin-unpin.md | 0 {src => en/src}/async/stream.md | 0 {src => en/src}/basic-types/char-bool-unit.md | 0 {src => en/src}/basic-types/functions.md | 0 {src => en/src}/basic-types/intro.md | 0 {src => en/src}/basic-types/numbers.md | 0 .../basic-types/statements-expressions.md | 0 {src => en/src}/circle-refer | 0 {src => en/src}/circle-reference/intro.md | 0 {src => en/src}/collections/hashmap.md | 0 {src => en/src}/collections/intro.md | 0 {src => en/src}/collections/vector.md | 0 {src => en/src}/comments-docs.md | 0 {src => en/src}/compound-types/array.md | 0 {src => en/src}/compound-types/enum.md | 0 {src => en/src}/compound-types/intro.md | 0 .../src}/compound-types/string-slice.md | 0 {src => en/src}/compound-types/struct.md | 0 {src => en/src}/compound-types/tuple.md | 0 {src => en/src}/crate | 0 {src => en/src}/crate-module/crate.md | 0 {src => en/src}/crate-module/intro.md | 0 {src => en/src}/crate-module/module.md | 0 {src => en/src}/crate-module/use-pub.md | 0 {src => en/src}/errors.md | 0 {src => en/src}/flow-control.md | 0 {src => en/src}/formatted-output.md | 0 .../src}/functional-programing/cloure.md | 0 .../src}/functional-programing/intro.md | 0 .../src}/functional-programing/iterator.md | 0 .../src}/functional-programming/closure.md | 0 .../src}/functional-programming/intro.md | 0 .../src}/generics-traits/advance-traits.md | 0 {src => en/src}/generics-traits/generics.md | 0 {src => en/src}/generics-traits/intro.md | 0 .../src}/generics-traits/trait-object.md | 0 {src => en/src}/generics-traits/traits.md | 0 {src => en/src}/global-variables.md | 0 {src => en/src}/lifetime/advance.md | 0 {src => en/src}/lifetime/basic.md | 0 {src => en/src}/lifetime/intro.md | 0 {src => en/src}/lifetime/static.md | 0 {src => en/src}/macro.md | 0 {src => en/src}/method.md | 0 {src => en/src}/newtype-sized.md | 0 {src => en/src}/ownership/borrowing.md | 0 {src => en/src}/ownership/intro.md | 0 {src => en/src}/ownership/ownership.md | 0 {src => en/src}/pattern-match/intro.md | 0 {src => en/src}/pattern-match/match-iflet.md | 0 {src => en/src}/pattern-match/option.md | 0 {src => en/src}/pattern-match/patterns.md | 0 {src => en/src}/resu | 0 {src => en/src}/result-panic/intro.md | 0 {src => en/src}/result-panic/panic.md | 0 {src => en/src}/result-panic/result.md | 0 {src => en/src}/self-referential.md | 0 {src => en/src}/smart-pointers/box.md | 0 .../src}/smart-pointers/cell-refcell.md | 0 {src => en/src}/smart-pointers/deref.md | 0 {src => en/src}/smart-pointers/drop.md | 0 {src => en/src}/smart-pointers/intro.md | 0 {src => en/src}/smart-pointers/rc-arc.md | 0 {src => en/src}/tests/assertions.md | 0 {src => en/src}/tests/benchmark.md | 0 {src => en/src}/tests/intro.md | 0 {src => en/src}/tests/unit-integration.md | 0 {src => en/src}/tests/write-tests.md | 0 {src => en/src}/threads/atomic.md | 0 {src => en/src}/threads/basic-using.md | 0 {src => en/src}/threads/intro.md | 0 {src => en/src}/threads/message-passing.md | 0 {src => en/src}/threads/send-sync.md | 0 {src => en/src}/threads/sync.md | 0 {src => en/src}/type-conversion.md | 0 {src => en/src}/unsafe.md | 0 {src => en/src}/variables.md | 0 {src => en/src}/weak.md | 0 {src => en/src}/why-exercise.md | 0 zh/.gitignore | 1 + zh/assets/CNAME | 1 + zh/book.toml | 20 +++++ zh/deploy | 21 +++++ zh/src/SUMMARY.md | 79 ++++++++++++++++++ zh/src/async/async-await.md | 1 + zh/src/async/future.md | 1 + zh/src/async/intro.md | 1 + zh/src/async/pin-unpin.md | 1 + zh/src/async/stream.md | 1 + zh/src/basic-types/char-bool-unit.md | 1 + zh/src/basic-types/functions.md | 1 + zh/src/basic-types/intro.md | 1 + zh/src/basic-types/numbers.md | 1 + zh/src/basic-types/statements-expressions.md | 1 + zh/src/circle-refer | 1 + zh/src/circle-reference/intro.md | 1 + zh/src/collections/hashmap.md | 1 + zh/src/collections/intro.md | 1 + zh/src/collections/vector.md | 1 + zh/src/comments-docs.md | 1 + zh/src/compound-types/array.md | 1 + zh/src/compound-types/enum.md | 1 + zh/src/compound-types/intro.md | 1 + zh/src/compound-types/string-slice.md | 1 + zh/src/compound-types/struct.md | 1 + zh/src/compound-types/tuple.md | 1 + zh/src/crate | 1 + zh/src/crate-module/crate.md | 1 + zh/src/crate-module/intro.md | 1 + zh/src/crate-module/module.md | 1 + zh/src/crate-module/use-pub.md | 1 + zh/src/errors.md | 1 + zh/src/flow-control.md | 1 + zh/src/formatted-output.md | 1 + zh/src/functional-programing/cloure.md | 51 +++++++++++ zh/src/functional-programing/intro.md | 1 + zh/src/functional-programing/iterator.md | 1 + zh/src/functional-programming/closure.md | 51 +++++++++++ zh/src/functional-programming/intro.md | 1 + zh/src/generics-traits/advance-traits.md | 1 + zh/src/generics-traits/generics.md | 1 + zh/src/generics-traits/intro.md | 1 + zh/src/generics-traits/trait-object.md | 1 + zh/src/generics-traits/traits.md | 1 + zh/src/global-variables.md | 1 + zh/src/lifetime/advance.md | 1 + zh/src/lifetime/basic.md | 26 ++++++ zh/src/lifetime/intro.md | 1 + zh/src/lifetime/static.md | 49 +++++++++++ zh/src/macro.md | 1 + zh/src/method.md | 1 + zh/src/newtype-sized.md | 1 + zh/src/ownership/borrowing.md | 1 + zh/src/ownership/intro.md | 1 + zh/src/ownership/ownership.md | 1 + zh/src/pattern-match/intro.md | 1 + zh/src/pattern-match/match-iflet.md | 1 + zh/src/pattern-match/option.md | 1 + zh/src/pattern-match/patterns.md | 1 + zh/src/resu | 1 + zh/src/result-panic/intro.md | 1 + zh/src/result-panic/panic.md | 1 + zh/src/result-panic/result.md | 1 + zh/src/self-referential.md | 1 + zh/src/smart-pointers/box.md | 1 + zh/src/smart-pointers/cell-refcell.md | 1 + zh/src/smart-pointers/deref.md | 1 + zh/src/smart-pointers/drop.md | 1 + zh/src/smart-pointers/intro.md | 1 + zh/src/smart-pointers/rc-arc.md | 1 + zh/src/tests/assertions.md | 1 + zh/src/tests/benchmark.md | 3 + zh/src/tests/intro.md | 1 + zh/src/tests/unit-integration.md | 1 + zh/src/tests/write-tests.md | 1 + zh/src/threads/atomic.md | 1 + zh/src/threads/basic-using.md | 1 + zh/src/threads/intro.md | 1 + zh/src/threads/message-passing.md | 1 + zh/src/threads/send-sync.md | 1 + zh/src/threads/sync.md | 1 + zh/src/type-conversion.md | 1 + zh/src/unsafe.md | 1 + zh/src/variables.md | 1 + zh/src/weak.md | 1 + zh/src/why-exercise.md | 1 + 175 files changed, 383 insertions(+), 4 deletions(-) create mode 100644 .DS_Store rename .gitignore => en/.gitignore (100%) rename {assets => en/assets}/CNAME (100%) rename book.toml => en/book.toml (58%) rename deploy => en/deploy (100%) rename {src => en/src}/SUMMARY.md (100%) rename {src => en/src}/async/async-await.md (100%) rename {src => en/src}/async/future.md (100%) rename {src => en/src}/async/intro.md (100%) rename {src => en/src}/async/pin-unpin.md (100%) rename {src => en/src}/async/stream.md (100%) rename {src => en/src}/basic-types/char-bool-unit.md (100%) rename {src => en/src}/basic-types/functions.md (100%) rename {src => en/src}/basic-types/intro.md (100%) rename {src => en/src}/basic-types/numbers.md (100%) rename {src => en/src}/basic-types/statements-expressions.md (100%) rename {src => en/src}/circle-refer (100%) rename {src => en/src}/circle-reference/intro.md (100%) rename {src => en/src}/collections/hashmap.md (100%) rename {src => en/src}/collections/intro.md (100%) rename {src => en/src}/collections/vector.md (100%) rename {src => en/src}/comments-docs.md (100%) rename {src => en/src}/compound-types/array.md (100%) rename {src => en/src}/compound-types/enum.md (100%) rename {src => en/src}/compound-types/intro.md (100%) rename {src => en/src}/compound-types/string-slice.md (100%) rename {src => en/src}/compound-types/struct.md (100%) rename {src => en/src}/compound-types/tuple.md (100%) rename {src => en/src}/crate (100%) rename {src => en/src}/crate-module/crate.md (100%) rename {src => en/src}/crate-module/intro.md (100%) rename {src => en/src}/crate-module/module.md (100%) rename {src => en/src}/crate-module/use-pub.md (100%) rename {src => en/src}/errors.md (100%) rename {src => en/src}/flow-control.md (100%) rename {src => en/src}/formatted-output.md (100%) rename {src => en/src}/functional-programing/cloure.md (100%) rename {src => en/src}/functional-programing/intro.md (100%) rename {src => en/src}/functional-programing/iterator.md (100%) rename {src => en/src}/functional-programming/closure.md (100%) rename {src => en/src}/functional-programming/intro.md (100%) rename {src => en/src}/generics-traits/advance-traits.md (100%) rename {src => en/src}/generics-traits/generics.md (100%) rename {src => en/src}/generics-traits/intro.md (100%) rename {src => en/src}/generics-traits/trait-object.md (100%) rename {src => en/src}/generics-traits/traits.md (100%) rename {src => en/src}/global-variables.md (100%) rename {src => en/src}/lifetime/advance.md (100%) rename {src => en/src}/lifetime/basic.md (100%) rename {src => en/src}/lifetime/intro.md (100%) rename {src => en/src}/lifetime/static.md (100%) rename {src => en/src}/macro.md (100%) rename {src => en/src}/method.md (100%) rename {src => en/src}/newtype-sized.md (100%) rename {src => en/src}/ownership/borrowing.md (100%) rename {src => en/src}/ownership/intro.md (100%) rename {src => en/src}/ownership/ownership.md (100%) rename {src => en/src}/pattern-match/intro.md (100%) rename {src => en/src}/pattern-match/match-iflet.md (100%) rename {src => en/src}/pattern-match/option.md (100%) rename {src => en/src}/pattern-match/patterns.md (100%) rename {src => en/src}/resu (100%) rename {src => en/src}/result-panic/intro.md (100%) rename {src => en/src}/result-panic/panic.md (100%) rename {src => en/src}/result-panic/result.md (100%) rename {src => en/src}/self-referential.md (100%) rename {src => en/src}/smart-pointers/box.md (100%) rename {src => en/src}/smart-pointers/cell-refcell.md (100%) rename {src => en/src}/smart-pointers/deref.md (100%) rename {src => en/src}/smart-pointers/drop.md (100%) rename {src => en/src}/smart-pointers/intro.md (100%) rename {src => en/src}/smart-pointers/rc-arc.md (100%) rename {src => en/src}/tests/assertions.md (100%) rename {src => en/src}/tests/benchmark.md (100%) rename {src => en/src}/tests/intro.md (100%) rename {src => en/src}/tests/unit-integration.md (100%) rename {src => en/src}/tests/write-tests.md (100%) rename {src => en/src}/threads/atomic.md (100%) rename {src => en/src}/threads/basic-using.md (100%) rename {src => en/src}/threads/intro.md (100%) rename {src => en/src}/threads/message-passing.md (100%) rename {src => en/src}/threads/send-sync.md (100%) rename {src => en/src}/threads/sync.md (100%) rename {src => en/src}/type-conversion.md (100%) rename {src => en/src}/unsafe.md (100%) rename {src => en/src}/variables.md (100%) rename {src => en/src}/weak.md (100%) rename {src => en/src}/why-exercise.md (100%) create mode 100644 zh/.gitignore create mode 100644 zh/assets/CNAME create mode 100644 zh/book.toml create mode 100755 zh/deploy create mode 100644 zh/src/SUMMARY.md create mode 100644 zh/src/async/async-await.md create mode 100644 zh/src/async/future.md create mode 100644 zh/src/async/intro.md create mode 100644 zh/src/async/pin-unpin.md create mode 100644 zh/src/async/stream.md create mode 100644 zh/src/basic-types/char-bool-unit.md create mode 100644 zh/src/basic-types/functions.md create mode 100644 zh/src/basic-types/intro.md create mode 100644 zh/src/basic-types/numbers.md create mode 100644 zh/src/basic-types/statements-expressions.md create mode 100644 zh/src/circle-refer create mode 100644 zh/src/circle-reference/intro.md create mode 100644 zh/src/collections/hashmap.md create mode 100644 zh/src/collections/intro.md create mode 100644 zh/src/collections/vector.md create mode 100644 zh/src/comments-docs.md create mode 100644 zh/src/compound-types/array.md create mode 100644 zh/src/compound-types/enum.md create mode 100644 zh/src/compound-types/intro.md create mode 100644 zh/src/compound-types/string-slice.md create mode 100644 zh/src/compound-types/struct.md create mode 100644 zh/src/compound-types/tuple.md create mode 100644 zh/src/crate create mode 100644 zh/src/crate-module/crate.md create mode 100644 zh/src/crate-module/intro.md create mode 100644 zh/src/crate-module/module.md create mode 100644 zh/src/crate-module/use-pub.md create mode 100644 zh/src/errors.md create mode 100644 zh/src/flow-control.md create mode 100644 zh/src/formatted-output.md create mode 100644 zh/src/functional-programing/cloure.md create mode 100644 zh/src/functional-programing/intro.md create mode 100644 zh/src/functional-programing/iterator.md create mode 100644 zh/src/functional-programming/closure.md create mode 100644 zh/src/functional-programming/intro.md create mode 100644 zh/src/generics-traits/advance-traits.md create mode 100644 zh/src/generics-traits/generics.md create mode 100644 zh/src/generics-traits/intro.md create mode 100644 zh/src/generics-traits/trait-object.md create mode 100644 zh/src/generics-traits/traits.md create mode 100644 zh/src/global-variables.md create mode 100644 zh/src/lifetime/advance.md create mode 100644 zh/src/lifetime/basic.md create mode 100644 zh/src/lifetime/intro.md create mode 100644 zh/src/lifetime/static.md create mode 100644 zh/src/macro.md create mode 100644 zh/src/method.md create mode 100644 zh/src/newtype-sized.md create mode 100644 zh/src/ownership/borrowing.md create mode 100644 zh/src/ownership/intro.md create mode 100644 zh/src/ownership/ownership.md create mode 100644 zh/src/pattern-match/intro.md create mode 100644 zh/src/pattern-match/match-iflet.md create mode 100644 zh/src/pattern-match/option.md create mode 100644 zh/src/pattern-match/patterns.md create mode 100644 zh/src/resu create mode 100644 zh/src/result-panic/intro.md create mode 100644 zh/src/result-panic/panic.md create mode 100644 zh/src/result-panic/result.md create mode 100644 zh/src/self-referential.md create mode 100644 zh/src/smart-pointers/box.md create mode 100644 zh/src/smart-pointers/cell-refcell.md create mode 100644 zh/src/smart-pointers/deref.md create mode 100644 zh/src/smart-pointers/drop.md create mode 100644 zh/src/smart-pointers/intro.md create mode 100644 zh/src/smart-pointers/rc-arc.md create mode 100644 zh/src/tests/assertions.md create mode 100644 zh/src/tests/benchmark.md create mode 100644 zh/src/tests/intro.md create mode 100644 zh/src/tests/unit-integration.md create mode 100644 zh/src/tests/write-tests.md create mode 100644 zh/src/threads/atomic.md create mode 100644 zh/src/threads/basic-using.md create mode 100644 zh/src/threads/intro.md create mode 100644 zh/src/threads/message-passing.md create mode 100644 zh/src/threads/send-sync.md create mode 100644 zh/src/threads/sync.md create mode 100644 zh/src/type-conversion.md create mode 100644 zh/src/unsafe.md create mode 100644 zh/src/variables.md create mode 100644 zh/src/weak.md create mode 100644 zh/src/why-exercise.md diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..1c840f64c824bb41506efb253e87aaea32bc7984 GIT binary patch literal 6148 zcmeHK%Sr=55bRz9M!e+cMVK!L_y=Q%2e0}A8dvcU4J3H+w0A$oPt>aJR@`-Of{1j( zboI_(pDzCWVA3^+ECbg4ip zkP4&%slX2vz?n^(9y+E^1yX@j;8Owa4+Vu-13O3CI^gUH0OU2=3^A|&%qf92uyaHY zOg$CosTxlV^>nnC;MKs+(bGla@uBhMkH?GJ*D-!Ex@dJwp9-V`eFgTsI^+3&hF@m% zk>5|rS}KqV{4)h~vbosk literal 0 HcmV?d00001 diff --git a/.gitignore b/en/.gitignore similarity index 100% rename from .gitignore rename to en/.gitignore diff --git a/assets/CNAME b/en/assets/CNAME similarity index 100% rename from assets/CNAME rename to en/assets/CNAME diff --git a/book.toml b/en/book.toml similarity index 58% rename from book.toml rename to en/book.toml index 8de752d..f0e492b 100644 --- a/book.toml +++ b/en/book.toml @@ -1,10 +1,8 @@ [book] title = "Rust Exercise" description = "A set of exercises and examples to pratice various aspects of Rust, also for the rust course (book) at https://course.rs" -authors = ["course.rs"] +authors = ["sunface, https://im.dev"] language = "en" -multilingual = false -src = "src" [output.html.playpen] editable = true @@ -14,7 +12,9 @@ editor = "ace" enable = true [output.html] -git-repository-url = "https://github.com/course-rs/rust-exercise" +additional-js = ["assets/lang.js"] +git-repository-url = "https://github.com/sunface/rust-exercise" +edit-url-template = "https://github.com/sunface/rust-exercise/edit/master/{path}" [rust] edition = "2021" \ No newline at end of file diff --git a/deploy b/en/deploy similarity index 100% rename from deploy rename to en/deploy diff --git a/src/SUMMARY.md b/en/src/SUMMARY.md similarity index 100% rename from src/SUMMARY.md rename to en/src/SUMMARY.md diff --git a/src/async/async-await.md b/en/src/async/async-await.md similarity index 100% rename from src/async/async-await.md rename to en/src/async/async-await.md diff --git a/src/async/future.md b/en/src/async/future.md similarity index 100% rename from src/async/future.md rename to en/src/async/future.md diff --git a/src/async/intro.md b/en/src/async/intro.md similarity index 100% rename from src/async/intro.md rename to en/src/async/intro.md diff --git a/src/async/pin-unpin.md b/en/src/async/pin-unpin.md similarity index 100% rename from src/async/pin-unpin.md rename to en/src/async/pin-unpin.md diff --git a/src/async/stream.md b/en/src/async/stream.md similarity index 100% rename from src/async/stream.md rename to en/src/async/stream.md diff --git a/src/basic-types/char-bool-unit.md b/en/src/basic-types/char-bool-unit.md similarity index 100% rename from src/basic-types/char-bool-unit.md rename to en/src/basic-types/char-bool-unit.md diff --git a/src/basic-types/functions.md b/en/src/basic-types/functions.md similarity index 100% rename from src/basic-types/functions.md rename to en/src/basic-types/functions.md diff --git a/src/basic-types/intro.md b/en/src/basic-types/intro.md similarity index 100% rename from src/basic-types/intro.md rename to en/src/basic-types/intro.md diff --git a/src/basic-types/numbers.md b/en/src/basic-types/numbers.md similarity index 100% rename from src/basic-types/numbers.md rename to en/src/basic-types/numbers.md diff --git a/src/basic-types/statements-expressions.md b/en/src/basic-types/statements-expressions.md similarity index 100% rename from src/basic-types/statements-expressions.md rename to en/src/basic-types/statements-expressions.md diff --git a/src/circle-refer b/en/src/circle-refer similarity index 100% rename from src/circle-refer rename to en/src/circle-refer diff --git a/src/circle-reference/intro.md b/en/src/circle-reference/intro.md similarity index 100% rename from src/circle-reference/intro.md rename to en/src/circle-reference/intro.md diff --git a/src/collections/hashmap.md b/en/src/collections/hashmap.md similarity index 100% rename from src/collections/hashmap.md rename to en/src/collections/hashmap.md diff --git a/src/collections/intro.md b/en/src/collections/intro.md similarity index 100% rename from src/collections/intro.md rename to en/src/collections/intro.md diff --git a/src/collections/vector.md b/en/src/collections/vector.md similarity index 100% rename from src/collections/vector.md rename to en/src/collections/vector.md diff --git a/src/comments-docs.md b/en/src/comments-docs.md similarity index 100% rename from src/comments-docs.md rename to en/src/comments-docs.md diff --git a/src/compound-types/array.md b/en/src/compound-types/array.md similarity index 100% rename from src/compound-types/array.md rename to en/src/compound-types/array.md diff --git a/src/compound-types/enum.md b/en/src/compound-types/enum.md similarity index 100% rename from src/compound-types/enum.md rename to en/src/compound-types/enum.md diff --git a/src/compound-types/intro.md b/en/src/compound-types/intro.md similarity index 100% rename from src/compound-types/intro.md rename to en/src/compound-types/intro.md diff --git a/src/compound-types/string-slice.md b/en/src/compound-types/string-slice.md similarity index 100% rename from src/compound-types/string-slice.md rename to en/src/compound-types/string-slice.md diff --git a/src/compound-types/struct.md b/en/src/compound-types/struct.md similarity index 100% rename from src/compound-types/struct.md rename to en/src/compound-types/struct.md diff --git a/src/compound-types/tuple.md b/en/src/compound-types/tuple.md similarity index 100% rename from src/compound-types/tuple.md rename to en/src/compound-types/tuple.md diff --git a/src/crate b/en/src/crate similarity index 100% rename from src/crate rename to en/src/crate diff --git a/src/crate-module/crate.md b/en/src/crate-module/crate.md similarity index 100% rename from src/crate-module/crate.md rename to en/src/crate-module/crate.md diff --git a/src/crate-module/intro.md b/en/src/crate-module/intro.md similarity index 100% rename from src/crate-module/intro.md rename to en/src/crate-module/intro.md diff --git a/src/crate-module/module.md b/en/src/crate-module/module.md similarity index 100% rename from src/crate-module/module.md rename to en/src/crate-module/module.md diff --git a/src/crate-module/use-pub.md b/en/src/crate-module/use-pub.md similarity index 100% rename from src/crate-module/use-pub.md rename to en/src/crate-module/use-pub.md diff --git a/src/errors.md b/en/src/errors.md similarity index 100% rename from src/errors.md rename to en/src/errors.md diff --git a/src/flow-control.md b/en/src/flow-control.md similarity index 100% rename from src/flow-control.md rename to en/src/flow-control.md diff --git a/src/formatted-output.md b/en/src/formatted-output.md similarity index 100% rename from src/formatted-output.md rename to en/src/formatted-output.md diff --git a/src/functional-programing/cloure.md b/en/src/functional-programing/cloure.md similarity index 100% rename from src/functional-programing/cloure.md rename to en/src/functional-programing/cloure.md diff --git a/src/functional-programing/intro.md b/en/src/functional-programing/intro.md similarity index 100% rename from src/functional-programing/intro.md rename to en/src/functional-programing/intro.md diff --git a/src/functional-programing/iterator.md b/en/src/functional-programing/iterator.md similarity index 100% rename from src/functional-programing/iterator.md rename to en/src/functional-programing/iterator.md diff --git a/src/functional-programming/closure.md b/en/src/functional-programming/closure.md similarity index 100% rename from src/functional-programming/closure.md rename to en/src/functional-programming/closure.md diff --git a/src/functional-programming/intro.md b/en/src/functional-programming/intro.md similarity index 100% rename from src/functional-programming/intro.md rename to en/src/functional-programming/intro.md diff --git a/src/generics-traits/advance-traits.md b/en/src/generics-traits/advance-traits.md similarity index 100% rename from src/generics-traits/advance-traits.md rename to en/src/generics-traits/advance-traits.md diff --git a/src/generics-traits/generics.md b/en/src/generics-traits/generics.md similarity index 100% rename from src/generics-traits/generics.md rename to en/src/generics-traits/generics.md diff --git a/src/generics-traits/intro.md b/en/src/generics-traits/intro.md similarity index 100% rename from src/generics-traits/intro.md rename to en/src/generics-traits/intro.md diff --git a/src/generics-traits/trait-object.md b/en/src/generics-traits/trait-object.md similarity index 100% rename from src/generics-traits/trait-object.md rename to en/src/generics-traits/trait-object.md diff --git a/src/generics-traits/traits.md b/en/src/generics-traits/traits.md similarity index 100% rename from src/generics-traits/traits.md rename to en/src/generics-traits/traits.md diff --git a/src/global-variables.md b/en/src/global-variables.md similarity index 100% rename from src/global-variables.md rename to en/src/global-variables.md diff --git a/src/lifetime/advance.md b/en/src/lifetime/advance.md similarity index 100% rename from src/lifetime/advance.md rename to en/src/lifetime/advance.md diff --git a/src/lifetime/basic.md b/en/src/lifetime/basic.md similarity index 100% rename from src/lifetime/basic.md rename to en/src/lifetime/basic.md diff --git a/src/lifetime/intro.md b/en/src/lifetime/intro.md similarity index 100% rename from src/lifetime/intro.md rename to en/src/lifetime/intro.md diff --git a/src/lifetime/static.md b/en/src/lifetime/static.md similarity index 100% rename from src/lifetime/static.md rename to en/src/lifetime/static.md diff --git a/src/macro.md b/en/src/macro.md similarity index 100% rename from src/macro.md rename to en/src/macro.md diff --git a/src/method.md b/en/src/method.md similarity index 100% rename from src/method.md rename to en/src/method.md diff --git a/src/newtype-sized.md b/en/src/newtype-sized.md similarity index 100% rename from src/newtype-sized.md rename to en/src/newtype-sized.md diff --git a/src/ownership/borrowing.md b/en/src/ownership/borrowing.md similarity index 100% rename from src/ownership/borrowing.md rename to en/src/ownership/borrowing.md diff --git a/src/ownership/intro.md b/en/src/ownership/intro.md similarity index 100% rename from src/ownership/intro.md rename to en/src/ownership/intro.md diff --git a/src/ownership/ownership.md b/en/src/ownership/ownership.md similarity index 100% rename from src/ownership/ownership.md rename to en/src/ownership/ownership.md diff --git a/src/pattern-match/intro.md b/en/src/pattern-match/intro.md similarity index 100% rename from src/pattern-match/intro.md rename to en/src/pattern-match/intro.md diff --git a/src/pattern-match/match-iflet.md b/en/src/pattern-match/match-iflet.md similarity index 100% rename from src/pattern-match/match-iflet.md rename to en/src/pattern-match/match-iflet.md diff --git a/src/pattern-match/option.md b/en/src/pattern-match/option.md similarity index 100% rename from src/pattern-match/option.md rename to en/src/pattern-match/option.md diff --git a/src/pattern-match/patterns.md b/en/src/pattern-match/patterns.md similarity index 100% rename from src/pattern-match/patterns.md rename to en/src/pattern-match/patterns.md diff --git a/src/resu b/en/src/resu similarity index 100% rename from src/resu rename to en/src/resu diff --git a/src/result-panic/intro.md b/en/src/result-panic/intro.md similarity index 100% rename from src/result-panic/intro.md rename to en/src/result-panic/intro.md diff --git a/src/result-panic/panic.md b/en/src/result-panic/panic.md similarity index 100% rename from src/result-panic/panic.md rename to en/src/result-panic/panic.md diff --git a/src/result-panic/result.md b/en/src/result-panic/result.md similarity index 100% rename from src/result-panic/result.md rename to en/src/result-panic/result.md diff --git a/src/self-referential.md b/en/src/self-referential.md similarity index 100% rename from src/self-referential.md rename to en/src/self-referential.md diff --git a/src/smart-pointers/box.md b/en/src/smart-pointers/box.md similarity index 100% rename from src/smart-pointers/box.md rename to en/src/smart-pointers/box.md diff --git a/src/smart-pointers/cell-refcell.md b/en/src/smart-pointers/cell-refcell.md similarity index 100% rename from src/smart-pointers/cell-refcell.md rename to en/src/smart-pointers/cell-refcell.md diff --git a/src/smart-pointers/deref.md b/en/src/smart-pointers/deref.md similarity index 100% rename from src/smart-pointers/deref.md rename to en/src/smart-pointers/deref.md diff --git a/src/smart-pointers/drop.md b/en/src/smart-pointers/drop.md similarity index 100% rename from src/smart-pointers/drop.md rename to en/src/smart-pointers/drop.md diff --git a/src/smart-pointers/intro.md b/en/src/smart-pointers/intro.md similarity index 100% rename from src/smart-pointers/intro.md rename to en/src/smart-pointers/intro.md diff --git a/src/smart-pointers/rc-arc.md b/en/src/smart-pointers/rc-arc.md similarity index 100% rename from src/smart-pointers/rc-arc.md rename to en/src/smart-pointers/rc-arc.md diff --git a/src/tests/assertions.md b/en/src/tests/assertions.md similarity index 100% rename from src/tests/assertions.md rename to en/src/tests/assertions.md diff --git a/src/tests/benchmark.md b/en/src/tests/benchmark.md similarity index 100% rename from src/tests/benchmark.md rename to en/src/tests/benchmark.md diff --git a/src/tests/intro.md b/en/src/tests/intro.md similarity index 100% rename from src/tests/intro.md rename to en/src/tests/intro.md diff --git a/src/tests/unit-integration.md b/en/src/tests/unit-integration.md similarity index 100% rename from src/tests/unit-integration.md rename to en/src/tests/unit-integration.md diff --git a/src/tests/write-tests.md b/en/src/tests/write-tests.md similarity index 100% rename from src/tests/write-tests.md rename to en/src/tests/write-tests.md diff --git a/src/threads/atomic.md b/en/src/threads/atomic.md similarity index 100% rename from src/threads/atomic.md rename to en/src/threads/atomic.md diff --git a/src/threads/basic-using.md b/en/src/threads/basic-using.md similarity index 100% rename from src/threads/basic-using.md rename to en/src/threads/basic-using.md diff --git a/src/threads/intro.md b/en/src/threads/intro.md similarity index 100% rename from src/threads/intro.md rename to en/src/threads/intro.md diff --git a/src/threads/message-passing.md b/en/src/threads/message-passing.md similarity index 100% rename from src/threads/message-passing.md rename to en/src/threads/message-passing.md diff --git a/src/threads/send-sync.md b/en/src/threads/send-sync.md similarity index 100% rename from src/threads/send-sync.md rename to en/src/threads/send-sync.md diff --git a/src/threads/sync.md b/en/src/threads/sync.md similarity index 100% rename from src/threads/sync.md rename to en/src/threads/sync.md diff --git a/src/type-conversion.md b/en/src/type-conversion.md similarity index 100% rename from src/type-conversion.md rename to en/src/type-conversion.md diff --git a/src/unsafe.md b/en/src/unsafe.md similarity index 100% rename from src/unsafe.md rename to en/src/unsafe.md diff --git a/src/variables.md b/en/src/variables.md similarity index 100% rename from src/variables.md rename to en/src/variables.md diff --git a/src/weak.md b/en/src/weak.md similarity index 100% rename from src/weak.md rename to en/src/weak.md diff --git a/src/why-exercise.md b/en/src/why-exercise.md similarity index 100% rename from src/why-exercise.md rename to en/src/why-exercise.md diff --git a/zh/.gitignore b/zh/.gitignore new file mode 100644 index 0000000..7585238 --- /dev/null +++ b/zh/.gitignore @@ -0,0 +1 @@ +book diff --git a/zh/assets/CNAME b/zh/assets/CNAME new file mode 100644 index 0000000..d893176 --- /dev/null +++ b/zh/assets/CNAME @@ -0,0 +1 @@ +zh.exercise.rs \ No newline at end of file diff --git a/zh/book.toml b/zh/book.toml new file mode 100644 index 0000000..f0e492b --- /dev/null +++ b/zh/book.toml @@ -0,0 +1,20 @@ +[book] +title = "Rust Exercise" +description = "A set of exercises and examples to pratice various aspects of Rust, also for the rust course (book) at https://course.rs" +authors = ["sunface, https://im.dev"] +language = "en" + +[output.html.playpen] +editable = true +editor = "ace" + +[output.html.fold] +enable = true + +[output.html] +additional-js = ["assets/lang.js"] +git-repository-url = "https://github.com/sunface/rust-exercise" +edit-url-template = "https://github.com/sunface/rust-exercise/edit/master/{path}" + +[rust] +edition = "2021" \ No newline at end of file diff --git a/zh/deploy b/zh/deploy new file mode 100755 index 0000000..b45e213 --- /dev/null +++ b/zh/deploy @@ -0,0 +1,21 @@ +## this script deploys the static website of course.rs to github pages + +## build static website for book +mdbook build +## copy CNAME info to book dir +cp ./assets/CNAME ./book/ +cp ./assets/*.html ./book/ +cp ./assets/sitemap.xml ./book/ + +## init git repo +cd book +git init +git config user.name "sunface" +git config user.email "cto@188.com" +git add . +git commit -m 'deploy' +git branch -M gh-pages +git remote add origin https://github.com/course-rs/rust-exercise + +## push to github pages +git push -u -f origin gh-pages \ No newline at end of file diff --git a/zh/src/SUMMARY.md b/zh/src/SUMMARY.md new file mode 100644 index 0000000..1bd5e42 --- /dev/null +++ b/zh/src/SUMMARY.md @@ -0,0 +1,79 @@ +# Summary + +- [Why Exercise.rs](why-exercise.md) +- [Variables](variables.md) +- [Basic Types](basic-types/intro.md) + - [Numbers](basic-types/numbers.md) + - [Char, Bool and Unit](basic-types/char-bool-unit.md) + - [Statements and Expressions](basic-types/statements-expressions.md) + - [Functions](basic-types/functions.md) +- [Ownership and Borrowing](ownership/intro.md) + - [Ownership](ownership/ownership.md) + - [Reference and Borrowing](ownership/borrowing.md) +- [Compound Types](compound-types/intro.md) + - [string and slice](compound-types/string-slice.md) + - [tuple](compound-types/tuple.md) + - [struct](compound-types/struct.md) + - [enum](compound-types/enum.md) + - [array](compound-types/array.md) +- [Flow Control](flow-control.md) +- [Pattern Match](pattern-match/intro.md) + - [match, if let](pattern-match/match-iflet.md) + - [Option destructing](pattern-match/option.md) + - [Patterns](pattern-match/patterns.md) +- [Method](method.md) +- [Generics and Traits](generics-traits/intro.md) + - [Generics](generics-traits/generics.md) + - [Traits](generics-traits/traits.md) + - [Trait Object](generics-traits/trait-object.md) + - [Advance Traits](generics-traits/advance-traits.md) +- [Collection Types](collections/intro.md) + - [Vector](collections/vector.md) + - [HashMap](collections/hashmap.md) +- [Type Conversion](type-conversion.md) +- [Result and panic](result-panic/intro.md) + - [panic!](result-panic/panic.md) + - [result and ?](result-panic/result.md) +- [Crate and module](crate-module/intro.md) + - [Crate](crate-module/crate.md) + - [Module](crate-module/module.md) + - [use and pub](crate-module/use-pub.md) +- [Comments and Docs](comments-docs.md) +- [Formatted output](formatted-output.md) +- [Lifetime](lifetime/intro.md) + - [basic](lifetime/basic.md) + - [&'static and T: 'static](lifetime/static.md) + - [advance](lifetime/advance.md) +- [Functional programing](functional-programing/intro.md) + - [Closure](functional-programing/cloure.md) + - [Iterator](functional-programing/iterator.md) +- [newtype and Sized](newtype-sized.md) +- [Smart pointers](smart-pointers/intro.md) + - [Box](smart-pointers/box.md) + - [Deref](smart-pointers/deref.md) + - [Drop](smart-pointers/drop.md) + - [Rc and Arc](smart-pointers/rc-arc.md) + - [Cell and RefCell](smart-pointers/cell-refcell.md) +- [Weak and Circle reference](weak.md) +- [Self referential](self-referential.md) +- [Threads](threads/intro.md) + - [Basic using](threads/basic-using.md) + - [Message passing](threads/message-passing.md) + - [Sync](threads/sync.md) + - [Atomic](threads/atomic.md) + - [Send and Sync](threads/send-sync.md) +- [Global variables](global-variables.md) +- [Errors](errors.md) +- [unsafe](unsafe.md) +- [macro](macro.md) +- [Tests](tests/intro.md) + - [Write Tests](tests/write-tests.md) + - [Benchmark](tests/benchmark.md) + - [Unit and Integration](tests/unit-integration.md) + - [Assertions](tests/assertions.md) +- [Async/Await](async/intro.md) + - [async and await!](async/async-await.md) + - [Future](async/future.md) + - [Pin and Unpin](async/pin-unpin.md) + - [Stream](async/stream.md) + \ No newline at end of file diff --git a/zh/src/async/async-await.md b/zh/src/async/async-await.md new file mode 100644 index 0000000..a20c0b8 --- /dev/null +++ b/zh/src/async/async-await.md @@ -0,0 +1 @@ +# async and await! diff --git a/zh/src/async/future.md b/zh/src/async/future.md new file mode 100644 index 0000000..5f24b0e --- /dev/null +++ b/zh/src/async/future.md @@ -0,0 +1 @@ +# Future diff --git a/zh/src/async/intro.md b/zh/src/async/intro.md new file mode 100644 index 0000000..70bdb9f --- /dev/null +++ b/zh/src/async/intro.md @@ -0,0 +1 @@ +# Async/Await diff --git a/zh/src/async/pin-unpin.md b/zh/src/async/pin-unpin.md new file mode 100644 index 0000000..8655bd1 --- /dev/null +++ b/zh/src/async/pin-unpin.md @@ -0,0 +1 @@ +# Pin and Unpin diff --git a/zh/src/async/stream.md b/zh/src/async/stream.md new file mode 100644 index 0000000..867bd88 --- /dev/null +++ b/zh/src/async/stream.md @@ -0,0 +1 @@ +# Stream diff --git a/zh/src/basic-types/char-bool-unit.md b/zh/src/basic-types/char-bool-unit.md new file mode 100644 index 0000000..b406dee --- /dev/null +++ b/zh/src/basic-types/char-bool-unit.md @@ -0,0 +1 @@ +# Char, Bool and Unit diff --git a/zh/src/basic-types/functions.md b/zh/src/basic-types/functions.md new file mode 100644 index 0000000..0c5faf5 --- /dev/null +++ b/zh/src/basic-types/functions.md @@ -0,0 +1 @@ +# Functions diff --git a/zh/src/basic-types/intro.md b/zh/src/basic-types/intro.md new file mode 100644 index 0000000..2d47759 --- /dev/null +++ b/zh/src/basic-types/intro.md @@ -0,0 +1 @@ +# Basic Types diff --git a/zh/src/basic-types/numbers.md b/zh/src/basic-types/numbers.md new file mode 100644 index 0000000..bbdcf5e --- /dev/null +++ b/zh/src/basic-types/numbers.md @@ -0,0 +1 @@ +# Numbers diff --git a/zh/src/basic-types/statements-expressions.md b/zh/src/basic-types/statements-expressions.md new file mode 100644 index 0000000..d1f2555 --- /dev/null +++ b/zh/src/basic-types/statements-expressions.md @@ -0,0 +1 @@ +# Statements and Expressions diff --git a/zh/src/circle-refer b/zh/src/circle-refer new file mode 100644 index 0000000..04b7a8f --- /dev/null +++ b/zh/src/circle-refer @@ -0,0 +1 @@ +# Weak and Circle reference diff --git a/zh/src/circle-reference/intro.md b/zh/src/circle-reference/intro.md new file mode 100644 index 0000000..4f99ca5 --- /dev/null +++ b/zh/src/circle-reference/intro.md @@ -0,0 +1 @@ +# Circle reference and Self referential diff --git a/zh/src/collections/hashmap.md b/zh/src/collections/hashmap.md new file mode 100644 index 0000000..96e549d --- /dev/null +++ b/zh/src/collections/hashmap.md @@ -0,0 +1 @@ +# HashMap diff --git a/zh/src/collections/intro.md b/zh/src/collections/intro.md new file mode 100644 index 0000000..1bdd607 --- /dev/null +++ b/zh/src/collections/intro.md @@ -0,0 +1 @@ +# Collection Types diff --git a/zh/src/collections/vector.md b/zh/src/collections/vector.md new file mode 100644 index 0000000..a2303c1 --- /dev/null +++ b/zh/src/collections/vector.md @@ -0,0 +1 @@ +# Vector diff --git a/zh/src/comments-docs.md b/zh/src/comments-docs.md new file mode 100644 index 0000000..cb7d70d --- /dev/null +++ b/zh/src/comments-docs.md @@ -0,0 +1 @@ +# Comments and Docs diff --git a/zh/src/compound-types/array.md b/zh/src/compound-types/array.md new file mode 100644 index 0000000..92c587c --- /dev/null +++ b/zh/src/compound-types/array.md @@ -0,0 +1 @@ +# array diff --git a/zh/src/compound-types/enum.md b/zh/src/compound-types/enum.md new file mode 100644 index 0000000..298e31d --- /dev/null +++ b/zh/src/compound-types/enum.md @@ -0,0 +1 @@ +# enum diff --git a/zh/src/compound-types/intro.md b/zh/src/compound-types/intro.md new file mode 100644 index 0000000..0c35451 --- /dev/null +++ b/zh/src/compound-types/intro.md @@ -0,0 +1 @@ +# Compound Types diff --git a/zh/src/compound-types/string-slice.md b/zh/src/compound-types/string-slice.md new file mode 100644 index 0000000..9f17363 --- /dev/null +++ b/zh/src/compound-types/string-slice.md @@ -0,0 +1 @@ +# string and slice diff --git a/zh/src/compound-types/struct.md b/zh/src/compound-types/struct.md new file mode 100644 index 0000000..4b9489b --- /dev/null +++ b/zh/src/compound-types/struct.md @@ -0,0 +1 @@ +# struct diff --git a/zh/src/compound-types/tuple.md b/zh/src/compound-types/tuple.md new file mode 100644 index 0000000..ebbc1a7 --- /dev/null +++ b/zh/src/compound-types/tuple.md @@ -0,0 +1 @@ +# tuple diff --git a/zh/src/crate b/zh/src/crate new file mode 100644 index 0000000..e66fb06 --- /dev/null +++ b/zh/src/crate @@ -0,0 +1 @@ +# Crate diff --git a/zh/src/crate-module/crate.md b/zh/src/crate-module/crate.md new file mode 100644 index 0000000..e66fb06 --- /dev/null +++ b/zh/src/crate-module/crate.md @@ -0,0 +1 @@ +# Crate diff --git a/zh/src/crate-module/intro.md b/zh/src/crate-module/intro.md new file mode 100644 index 0000000..dadbf20 --- /dev/null +++ b/zh/src/crate-module/intro.md @@ -0,0 +1 @@ +# Crate and module diff --git a/zh/src/crate-module/module.md b/zh/src/crate-module/module.md new file mode 100644 index 0000000..b785ceb --- /dev/null +++ b/zh/src/crate-module/module.md @@ -0,0 +1 @@ +# Module diff --git a/zh/src/crate-module/use-pub.md b/zh/src/crate-module/use-pub.md new file mode 100644 index 0000000..60c6894 --- /dev/null +++ b/zh/src/crate-module/use-pub.md @@ -0,0 +1 @@ +# use and pub diff --git a/zh/src/errors.md b/zh/src/errors.md new file mode 100644 index 0000000..165d08c --- /dev/null +++ b/zh/src/errors.md @@ -0,0 +1 @@ +# Errors diff --git a/zh/src/flow-control.md b/zh/src/flow-control.md new file mode 100644 index 0000000..cf0c99f --- /dev/null +++ b/zh/src/flow-control.md @@ -0,0 +1 @@ +# Flow Control diff --git a/zh/src/formatted-output.md b/zh/src/formatted-output.md new file mode 100644 index 0000000..5cd8a3b --- /dev/null +++ b/zh/src/formatted-output.md @@ -0,0 +1 @@ +# Formatted output diff --git a/zh/src/functional-programing/cloure.md b/zh/src/functional-programing/cloure.md new file mode 100644 index 0000000..fb73740 --- /dev/null +++ b/zh/src/functional-programing/cloure.md @@ -0,0 +1,51 @@ +# Closure + +下面代码是Rust圣经课程中[闭包](http://course.rs/advance/functional-programing/closure.html#结构体中的闭包)章节的课内练习题答案: + +```rust +struct Cacher +where + T: Fn(E) -> E, + E: Copy +{ + query: T, + value: Option, +} + +impl Cacher +where + T: Fn(E) -> E, + E: Copy +{ + fn new(query: T) -> Cacher { + Cacher { + query, + value: None, + } + } + + fn value(&mut self, arg: E) -> E { + match self.value { + Some(v) => v, + None => { + let v = (self.query)(arg); + self.value = Some(v); + v + } + } + } +} +fn main() { + +} + +#[test] +fn call_with_different_values() { + let mut c = Cacher::new(|a| a); + + let v1 = c.value(1); + let v2 = c.value(2); + + assert_eq!(v2, 1); +} +``` \ No newline at end of file diff --git a/zh/src/functional-programing/intro.md b/zh/src/functional-programing/intro.md new file mode 100644 index 0000000..6f326b8 --- /dev/null +++ b/zh/src/functional-programing/intro.md @@ -0,0 +1 @@ +# Functional programing diff --git a/zh/src/functional-programing/iterator.md b/zh/src/functional-programing/iterator.md new file mode 100644 index 0000000..2a4a2aa --- /dev/null +++ b/zh/src/functional-programing/iterator.md @@ -0,0 +1 @@ +# Iterator diff --git a/zh/src/functional-programming/closure.md b/zh/src/functional-programming/closure.md new file mode 100644 index 0000000..fb73740 --- /dev/null +++ b/zh/src/functional-programming/closure.md @@ -0,0 +1,51 @@ +# Closure + +下面代码是Rust圣经课程中[闭包](http://course.rs/advance/functional-programing/closure.html#结构体中的闭包)章节的课内练习题答案: + +```rust +struct Cacher +where + T: Fn(E) -> E, + E: Copy +{ + query: T, + value: Option, +} + +impl Cacher +where + T: Fn(E) -> E, + E: Copy +{ + fn new(query: T) -> Cacher { + Cacher { + query, + value: None, + } + } + + fn value(&mut self, arg: E) -> E { + match self.value { + Some(v) => v, + None => { + let v = (self.query)(arg); + self.value = Some(v); + v + } + } + } +} +fn main() { + +} + +#[test] +fn call_with_different_values() { + let mut c = Cacher::new(|a| a); + + let v1 = c.value(1); + let v2 = c.value(2); + + assert_eq!(v2, 1); +} +``` \ No newline at end of file diff --git a/zh/src/functional-programming/intro.md b/zh/src/functional-programming/intro.md new file mode 100644 index 0000000..dca041e --- /dev/null +++ b/zh/src/functional-programming/intro.md @@ -0,0 +1 @@ +# Functional Programming diff --git a/zh/src/generics-traits/advance-traits.md b/zh/src/generics-traits/advance-traits.md new file mode 100644 index 0000000..8cd2f63 --- /dev/null +++ b/zh/src/generics-traits/advance-traits.md @@ -0,0 +1 @@ +# Advance Traits diff --git a/zh/src/generics-traits/generics.md b/zh/src/generics-traits/generics.md new file mode 100644 index 0000000..292d26b --- /dev/null +++ b/zh/src/generics-traits/generics.md @@ -0,0 +1 @@ +# Generics diff --git a/zh/src/generics-traits/intro.md b/zh/src/generics-traits/intro.md new file mode 100644 index 0000000..340ad0e --- /dev/null +++ b/zh/src/generics-traits/intro.md @@ -0,0 +1 @@ +# Generics and Traits diff --git a/zh/src/generics-traits/trait-object.md b/zh/src/generics-traits/trait-object.md new file mode 100644 index 0000000..38a0b34 --- /dev/null +++ b/zh/src/generics-traits/trait-object.md @@ -0,0 +1 @@ +# Trait Object diff --git a/zh/src/generics-traits/traits.md b/zh/src/generics-traits/traits.md new file mode 100644 index 0000000..445d444 --- /dev/null +++ b/zh/src/generics-traits/traits.md @@ -0,0 +1 @@ +# Traits diff --git a/zh/src/global-variables.md b/zh/src/global-variables.md new file mode 100644 index 0000000..ad85421 --- /dev/null +++ b/zh/src/global-variables.md @@ -0,0 +1 @@ +# Global variables diff --git a/zh/src/lifetime/advance.md b/zh/src/lifetime/advance.md new file mode 100644 index 0000000..4ee0e07 --- /dev/null +++ b/zh/src/lifetime/advance.md @@ -0,0 +1 @@ +# advance diff --git a/zh/src/lifetime/basic.md b/zh/src/lifetime/basic.md new file mode 100644 index 0000000..40439f4 --- /dev/null +++ b/zh/src/lifetime/basic.md @@ -0,0 +1,26 @@ +## 生命周期消除 + +```rust +fn print(s: &str); // elided +fn print<'a>(s: &'a str); // expanded + +fn debug(lvl: usize, s: &str); // elided +fn debug<'a>(lvl: usize, s: &'a str); // expanded + +fn substr(s: &str, until: usize) -> &str; // elided +fn substr<'a>(s: &'a str, until: usize) -> &'a str; // expanded + +fn get_str() -> &str; // ILLEGAL + +fn frob(s: &str, t: &str) -> &str; // ILLEGAL + +fn get_mut(&mut self) -> &mut T; // elided +fn get_mut<'a>(&'a mut self) -> &'a mut T; // expanded + +fn args(&mut self, args: &[T]) -> &mut Command // elided +fn args<'a, 'b, T: ToCStr>(&'a mut self, args: &'b [T]) -> &'a mut Command // expanded + +fn new(buf: &mut [u8]) -> BufWriter; // elided +fn new(buf: &mut [u8]) -> BufWriter<'_>; // elided (with `rust_2018_idioms`) +fn new<'a>(buf: &'a mut [u8]) -> BufWriter<'a> // expanded +``` \ No newline at end of file diff --git a/zh/src/lifetime/intro.md b/zh/src/lifetime/intro.md new file mode 100644 index 0000000..2615315 --- /dev/null +++ b/zh/src/lifetime/intro.md @@ -0,0 +1 @@ +# Lifetime diff --git a/zh/src/lifetime/static.md b/zh/src/lifetime/static.md new file mode 100644 index 0000000..782446e --- /dev/null +++ b/zh/src/lifetime/static.md @@ -0,0 +1,49 @@ +# &'static and T: 'static + +```rust,editable +use std::fmt::Display; + +fn main() { + let mut string = "First".to_owned(); + + string.push_str(string.to_uppercase().as_str()); + print_a(&string); + print_b(&string); + print_c(&string); // Compilation error + print_d(&string); // Compilation error + print_e(&string); + print_f(&string); + print_g(&string); // Compilation error +} + +fn print_a(t: &T) { + println!("{}", t); +} + +fn print_b(t: &T) +where + T: Display + 'static, +{ + println!("{}", t); +} + +fn print_c(t: &'static dyn Display) { + println!("{}", t) +} + +fn print_d(t: &'static impl Display) { + println!("{}", t) +} + +fn print_e(t: &(dyn Display + 'static)) { + println!("{}", t) +} + +fn print_f(t: &(impl Display + 'static)) { + println!("{}", t) +} + +fn print_g(t: &'static String) { + println!("{}", t); +} +``` \ No newline at end of file diff --git a/zh/src/macro.md b/zh/src/macro.md new file mode 100644 index 0000000..20503ba --- /dev/null +++ b/zh/src/macro.md @@ -0,0 +1 @@ +# macro diff --git a/zh/src/method.md b/zh/src/method.md new file mode 100644 index 0000000..81d5a1c --- /dev/null +++ b/zh/src/method.md @@ -0,0 +1 @@ +# Method diff --git a/zh/src/newtype-sized.md b/zh/src/newtype-sized.md new file mode 100644 index 0000000..fc3f074 --- /dev/null +++ b/zh/src/newtype-sized.md @@ -0,0 +1 @@ +# newtype and Sized diff --git a/zh/src/ownership/borrowing.md b/zh/src/ownership/borrowing.md new file mode 100644 index 0000000..9ce0535 --- /dev/null +++ b/zh/src/ownership/borrowing.md @@ -0,0 +1 @@ +# Reference and Borrowing diff --git a/zh/src/ownership/intro.md b/zh/src/ownership/intro.md new file mode 100644 index 0000000..e749a67 --- /dev/null +++ b/zh/src/ownership/intro.md @@ -0,0 +1 @@ +# Ownership and Borrowing diff --git a/zh/src/ownership/ownership.md b/zh/src/ownership/ownership.md new file mode 100644 index 0000000..77f5a52 --- /dev/null +++ b/zh/src/ownership/ownership.md @@ -0,0 +1 @@ +# Ownership diff --git a/zh/src/pattern-match/intro.md b/zh/src/pattern-match/intro.md new file mode 100644 index 0000000..ee4bb18 --- /dev/null +++ b/zh/src/pattern-match/intro.md @@ -0,0 +1 @@ +# Pattern Match diff --git a/zh/src/pattern-match/match-iflet.md b/zh/src/pattern-match/match-iflet.md new file mode 100644 index 0000000..18eed0e --- /dev/null +++ b/zh/src/pattern-match/match-iflet.md @@ -0,0 +1 @@ +# match, if let diff --git a/zh/src/pattern-match/option.md b/zh/src/pattern-match/option.md new file mode 100644 index 0000000..cb5ffa1 --- /dev/null +++ b/zh/src/pattern-match/option.md @@ -0,0 +1 @@ +# Option destructing diff --git a/zh/src/pattern-match/patterns.md b/zh/src/pattern-match/patterns.md new file mode 100644 index 0000000..3c9daa3 --- /dev/null +++ b/zh/src/pattern-match/patterns.md @@ -0,0 +1 @@ +# Patterns diff --git a/zh/src/resu b/zh/src/resu new file mode 100644 index 0000000..b82dd9a --- /dev/null +++ b/zh/src/resu @@ -0,0 +1 @@ +# panic! diff --git a/zh/src/result-panic/intro.md b/zh/src/result-panic/intro.md new file mode 100644 index 0000000..f724a70 --- /dev/null +++ b/zh/src/result-panic/intro.md @@ -0,0 +1 @@ +# Result and panic diff --git a/zh/src/result-panic/panic.md b/zh/src/result-panic/panic.md new file mode 100644 index 0000000..b82dd9a --- /dev/null +++ b/zh/src/result-panic/panic.md @@ -0,0 +1 @@ +# panic! diff --git a/zh/src/result-panic/result.md b/zh/src/result-panic/result.md new file mode 100644 index 0000000..7af6baf --- /dev/null +++ b/zh/src/result-panic/result.md @@ -0,0 +1 @@ +# result and ? diff --git a/zh/src/self-referential.md b/zh/src/self-referential.md new file mode 100644 index 0000000..37a4784 --- /dev/null +++ b/zh/src/self-referential.md @@ -0,0 +1 @@ +# Self referential diff --git a/zh/src/smart-pointers/box.md b/zh/src/smart-pointers/box.md new file mode 100644 index 0000000..2436f01 --- /dev/null +++ b/zh/src/smart-pointers/box.md @@ -0,0 +1 @@ +# Box diff --git a/zh/src/smart-pointers/cell-refcell.md b/zh/src/smart-pointers/cell-refcell.md new file mode 100644 index 0000000..4e61a02 --- /dev/null +++ b/zh/src/smart-pointers/cell-refcell.md @@ -0,0 +1 @@ +# Cell and RefCell diff --git a/zh/src/smart-pointers/deref.md b/zh/src/smart-pointers/deref.md new file mode 100644 index 0000000..8c709e8 --- /dev/null +++ b/zh/src/smart-pointers/deref.md @@ -0,0 +1 @@ +# Deref diff --git a/zh/src/smart-pointers/drop.md b/zh/src/smart-pointers/drop.md new file mode 100644 index 0000000..c6ecf82 --- /dev/null +++ b/zh/src/smart-pointers/drop.md @@ -0,0 +1 @@ +# Drop diff --git a/zh/src/smart-pointers/intro.md b/zh/src/smart-pointers/intro.md new file mode 100644 index 0000000..997d50c --- /dev/null +++ b/zh/src/smart-pointers/intro.md @@ -0,0 +1 @@ +# Smart pointers diff --git a/zh/src/smart-pointers/rc-arc.md b/zh/src/smart-pointers/rc-arc.md new file mode 100644 index 0000000..8f723ed --- /dev/null +++ b/zh/src/smart-pointers/rc-arc.md @@ -0,0 +1 @@ +# Rc and Arc diff --git a/zh/src/tests/assertions.md b/zh/src/tests/assertions.md new file mode 100644 index 0000000..f5743ab --- /dev/null +++ b/zh/src/tests/assertions.md @@ -0,0 +1 @@ +# Assertions diff --git a/zh/src/tests/benchmark.md b/zh/src/tests/benchmark.md new file mode 100644 index 0000000..f883201 --- /dev/null +++ b/zh/src/tests/benchmark.md @@ -0,0 +1,3 @@ +# Benchmark + +https://doc.rust-lang.org/unstable-book/library-features/test.html \ No newline at end of file diff --git a/zh/src/tests/intro.md b/zh/src/tests/intro.md new file mode 100644 index 0000000..007eb95 --- /dev/null +++ b/zh/src/tests/intro.md @@ -0,0 +1 @@ +# Tests diff --git a/zh/src/tests/unit-integration.md b/zh/src/tests/unit-integration.md new file mode 100644 index 0000000..68df7e4 --- /dev/null +++ b/zh/src/tests/unit-integration.md @@ -0,0 +1 @@ +# Unit and Integration diff --git a/zh/src/tests/write-tests.md b/zh/src/tests/write-tests.md new file mode 100644 index 0000000..245c701 --- /dev/null +++ b/zh/src/tests/write-tests.md @@ -0,0 +1 @@ +# Write Tests diff --git a/zh/src/threads/atomic.md b/zh/src/threads/atomic.md new file mode 100644 index 0000000..eecfaa8 --- /dev/null +++ b/zh/src/threads/atomic.md @@ -0,0 +1 @@ +# Atomic diff --git a/zh/src/threads/basic-using.md b/zh/src/threads/basic-using.md new file mode 100644 index 0000000..f0a2d46 --- /dev/null +++ b/zh/src/threads/basic-using.md @@ -0,0 +1 @@ +# Basic using diff --git a/zh/src/threads/intro.md b/zh/src/threads/intro.md new file mode 100644 index 0000000..f60f399 --- /dev/null +++ b/zh/src/threads/intro.md @@ -0,0 +1 @@ +# Threads diff --git a/zh/src/threads/message-passing.md b/zh/src/threads/message-passing.md new file mode 100644 index 0000000..4d33941 --- /dev/null +++ b/zh/src/threads/message-passing.md @@ -0,0 +1 @@ +# Message passing diff --git a/zh/src/threads/send-sync.md b/zh/src/threads/send-sync.md new file mode 100644 index 0000000..171f95f --- /dev/null +++ b/zh/src/threads/send-sync.md @@ -0,0 +1 @@ +# Send and Sync diff --git a/zh/src/threads/sync.md b/zh/src/threads/sync.md new file mode 100644 index 0000000..bc4491e --- /dev/null +++ b/zh/src/threads/sync.md @@ -0,0 +1 @@ +# Sync diff --git a/zh/src/type-conversion.md b/zh/src/type-conversion.md new file mode 100644 index 0000000..7b930e5 --- /dev/null +++ b/zh/src/type-conversion.md @@ -0,0 +1 @@ +# Type Conversion diff --git a/zh/src/unsafe.md b/zh/src/unsafe.md new file mode 100644 index 0000000..df49df6 --- /dev/null +++ b/zh/src/unsafe.md @@ -0,0 +1 @@ +# unsafe diff --git a/zh/src/variables.md b/zh/src/variables.md new file mode 100644 index 0000000..ee1fba4 --- /dev/null +++ b/zh/src/variables.md @@ -0,0 +1 @@ +# Variables diff --git a/zh/src/weak.md b/zh/src/weak.md new file mode 100644 index 0000000..04b7a8f --- /dev/null +++ b/zh/src/weak.md @@ -0,0 +1 @@ +# Weak and Circle reference diff --git a/zh/src/why-exercise.md b/zh/src/why-exercise.md new file mode 100644 index 0000000..c3e5e3f --- /dev/null +++ b/zh/src/why-exercise.md @@ -0,0 +1 @@ +# Why Exercise.rs