{"id":15364474,"url":"https://github.com/xadillax/zh-rust-by-example","last_synced_at":"2025-09-06T20:32:58.988Z","repository":{"id":25340901,"uuid":"28768289","full_name":"XadillaX/zh-rust-by-example","owner":"XadillaX","description":"跟着例子学 Rust（包含在线编辑器）中文版。http://rustbyexample.com","archived":false,"fork":false,"pushed_at":"2015-02-06T02:42:09.000Z","size":1768,"stargazers_count":4,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T18:51:51.668Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/XadillaX.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-01-04T08:02:32.000Z","updated_at":"2024-04-29T16:08:12.000Z","dependencies_parsed_at":"2022-08-23T06:00:18.055Z","dependency_job_id":null,"html_url":"https://github.com/XadillaX/zh-rust-by-example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XadillaX%2Fzh-rust-by-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XadillaX%2Fzh-rust-by-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XadillaX%2Fzh-rust-by-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/XadillaX%2Fzh-rust-by-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/XadillaX","download_url":"https://codeload.github.com/XadillaX/zh-rust-by-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249043210,"owners_count":21203431,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-01T13:11:52.214Z","updated_at":"2025-04-15T09:34:49.221Z","avatar_url":"https://github.com/XadillaX.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status][travis-image]][travis-link]\n# Rust 简例\n\n## 原项目\n\n该项目是从《[Rust by Example](https://github.com/rust-lang/rust-by-example)》中翻译过来的。\n\n## 什么 Gui？\n\n这是 [Rust 简例][website]的源代码！\n\n## 如何贡献？\n\n参照 [CONTRIBUTING.md][how-to-contribute]。\n\n## 如何生成静态页？\n\nFirst, make certain you install `nodejs` on Debian based distributions, or\n`node` on non-Debian distros. After installation, if you use a Debian based\ndistro (i.e. Ubuntu), run:\n\n    sudo ln -s /usr/bin/nodejs /usr/bin/node\n\nThen run:\n\n```\nmake all\nmake book\nmake test\n```\n\n输入 `make serve` 来查看结果。\n\n注意：在 Ubuntu 里 `node` 可能叫 `nodejs`。我不得不相应地修改 `.bin/gitbook`。\n\n### 详细说明\n\n我们使用下面的工具来生成这个静态站：\n\n* [Rust][rust-lang] (ﾉ◕ヮ◕)ﾉ\\*:･ﾟ✧\n* [gitbook][gitbook]\n\n`gitbook` 会从 Markdown 文件中生成页面（[点我](gitbook-format)看看它是怎么工作的）。\n\n在跑 `gitbook` 之前我们需要用 [src/update.rs][update-rs] 来做一些前置工作。\n\n这个工作包含两步：\n\n### 生成 `SUMMARY.md`\n\n`SUMMARY.md` 是通过 [examples/structure.json][structure] 生成的。这个 JSON\n文件包含了一个例子们的类树形结构。\n\n每个例子包含：\n\n* ID，如 `hello`\n* 标题，如 `Hello World`\n* 子节点，该项为可选项，包含了其子节点，如 `null`\n* 一个在 `examples` 目录下的子目录，如 [examples/hello][hello-folder]\n* 一个在 examples/structure.json 里面的入口点，如 `{ \"id\": \"hello\", \"title\":\n    \"Hello World\", \"children\": null }`\n  * 一些源文件，如 [examples/hello/hello.rs][hello-rs]\n* 一个输入 Markdown 文件，如 [examples/hello/input.md][hello-md]\n\nWhen dealing with a child example, the path will have to include the id of its\nancestors; e.g. `examples/variable/mut/input.md`, implies that a `mut` example\nlives under the `variable` example.\n\n### 处理 `input.md`\n\nRust 的代码我们不直接放在 `input.md` 里面，而是放在另外的源文件里面；然后前置工作会把源代码插入到\nmarkdown 文件里面。\n\n举个栗子，为了插入 `hello.rs`，我们会在 markdown 文件里面添加如下的标记：\n\n* `{hello.play}` 会把代码嵌入到一个在线编辑框里面。\n* `{hello.rs}` 会放到静态文本里面。\n* `{hello.out}` 会放这个程序的输出结果。\n\nMakefile 提供了以下指令：\n\n* `make`: 构建 `update.rs` 然后执行上述前置工作\n* `make book`: 执行 `gitbook` 来生成 book\n* `make serve`: 执行 `gitbook --serve` 来生成 book 然后以 `localhost:4000` 预览\n* `make test`: 会测试所有的 Rust 源文件是否有编译错误\n\n## 开源协议\n\nRust 简例包含了两种协议——Apache 2.0 以及 MIT 协议。请阅读该两种协议的详细内容。\n\n[travis-image]: https://travis-ci.org/rust-lang/rust-by-example.svg?branch=master\n[travis-link]: https://travis-ci.org/rust-lang/rust-by-example\n[website]: http://rustbyexample.com\n[how-to-contribute]: CONTRIBUTING.md\n[rust-lang]: http://www.rust-lang.org/\n[gitbook]: http://www.gitbook.io\n[gitbook-format]: https://github.com/GitbookIO/gitbook#book-format\n[main-rs]: src/main.rs\n[structure]: examples/structure.json\n[hello-folder]: examples/hello\n[hello-rs]: examples/hello/hello.rs\n[hello-md]: examples/hello/input.md\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxadillax%2Fzh-rust-by-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxadillax%2Fzh-rust-by-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxadillax%2Fzh-rust-by-example/lists"}