48 |
49 |
50 |
--------------------------------------------------------------------------------
/src/doc/machine-readable-output.md:
--------------------------------------------------------------------------------
1 | % Машиночитаемый вывод.
2 |
3 | Cargo может выдавать информацию о вашей сборке и вашем проекте в формате JSON.
4 | Cargo can output information about project and build in JSON format.
5 |
6 | # Информация о структуре проекта
7 |
8 | Вы можете использовать команду `cargo metadata` чтобы получить информацию о структуре проекта
9 | и зависимостях. Вывод данной команды будет примерно таким:
10 |
11 | ```text
12 | {
13 | // Версия формата сообщений .
14 | "version": integer,
15 |
16 | // Список пакетов для проекта, включая зависимости.
17 | "packages": [
18 | {
19 | // Уникальный идентификатор пакета.
20 | "id": PackageId,
21 |
22 | "name": string,
23 |
24 | "version": string,
25 |
26 | "source": SourceId,
27 |
28 | // Список объявленных зависимостей. Используемые зависимости описаны в пол `resolve`.
29 | "dependencies": [ Dependency ],
30 |
31 | "targets: [ Target ],
32 |
33 | // Путь до Cargo.toml
34 | "manifest_path": string,
35 | }
36 | ],
37 |
38 | "workspace_members": [ PackageId ],
39 |
40 | // Граф зависимостей.
41 | "resolve": {
42 | "nodes": [
43 | {
44 | "id": PackageId,
45 | "dependencies": [ PackageId ]
46 | }
47 | ]
48 | }
49 | }
50 | ```
51 |
52 |
53 | # Ошибки компилятора
54 |
55 | Если вы добавите параметр `--message-format json` для команд типа `cargo build`, Cargo
56 | выдаст ошибки и предупреждения компилятора в формате JSON. Сообщения будут выведены в
57 | стандартный поток вывода. Каждое сообщение занимает ровно одну строчку и не содержит в себе
58 | символа перевода строки `\n`. Благодаря этому их можно обрабатывать не дожидаясь окончания сборки.
59 |
60 | Формат сообщений выглядит примерно так:
61 |
62 | ```text
63 | {
64 | // Тип сообщения.
65 | "reason": "compiler-message",
66 |
67 | // Уникальный идентификатор компилируемого пакета.
68 | "package_id": PackageId,
69 |
70 | // Уникальный идентификатор для типа сборки (например, bin)
71 | "target": Target,
72 |
73 | // Сообщение от компилятора в формате JSON.
74 | "message": {...}
75 | }
76 | ```
77 |
78 | Спецификация пакетов и типов сборки такая же как и у `cargo metadata`.
79 |
--------------------------------------------------------------------------------
/src/doc/policies.md:
--------------------------------------------------------------------------------
1 | % Crates.io package policies
2 |
3 | In general, these policies are guidelines. Problems are often contextual, and
4 | exceptional circumstances sometimes require exceptional measures. We plan to
5 | continue to clarify and expand these rules over time as new circumstances
6 | arise.
7 |
8 | # Package Ownership
9 |
10 | We have a first-come, first-served policy on crate names. Upon publishing a
11 | package, the publisher will be made owner of the package on Crates.io.
12 |
13 | If someone wants to take over a package, and the previous owner agrees, the
14 | existing maintainer can add them as an owner, and the new maintainer can remove
15 | them. If necessary, the team may reach out to inactive maintainers and help
16 | mediate the process of ownership transfer.
17 |
18 | # Removal
19 |
20 | Many questions are specialized instances of a more general form: “Under what
21 | circumstances can a package be removed from Crates.io?”
22 |
23 | The short version is that packages are first-come, first-served, and we won’t
24 | attempt to get into policing what exactly makes a legitimate package. We will
25 | do what the law requires us to do, and address flagrant violations of the Rust
26 | Code of Conduct.
27 |
28 | ## Squatting
29 |
30 | We do not have any policies to define 'squatting', and so will not hand over
31 | ownership of a package for that reason.
32 |
33 |
34 | ## The Law
35 |
36 | For issues such as DMCA violations, trademark and copyright infringement,
37 | Crates.io will respect Mozilla Legal’s decisions with regards to content that
38 | is hosted.
39 |
40 | ## Code of Conduct
41 |
42 | The Rust project has a [Code of Conduct] which governs appropriate conduct for
43 | the Rust community. In general, any content on Crates.io that violates the Code
44 | of Conduct may be removed. There are two important, related aspects:
45 |
46 | - We will not be pro-actively monitoring the site for these kinds of violations,
47 | but relying on the community to draw them to our attention.
48 | - “Does this violate the Code of Conduct” is a contextual question that
49 | cannot be directly answered in the hypothetical sense. All of the details
50 | must be taken into consideration in these kinds of situations.
51 |
52 | [Code of Conduct]: https://www.rust-lang.org/conduct.html
53 |
--------------------------------------------------------------------------------
/src/doc/index.md:
--------------------------------------------------------------------------------
1 | % Cargo - менеджер пакетов для языка программирования Rust.
2 |
3 | # Установка
4 |
5 | Самый простой способ установить Cargo, это скачать последнюю стабильную версию Rust
6 | используя `rustup` скрипт:
7 |
8 | ```shell
9 | $ curl -sSf https://static.rust-lang.org/rustup.sh | sh
10 | ```
11 |
12 | После выполнения данного скрипта вы получите последнюю стабильную версию Rust для вашей платформы, а так же последнюю версию Cargo.
13 |
14 | Если вы используете операционную систему Windows, вы можете скачать установщики последней стабильной версии Rust и ночную сборку Cargo. 32-х битная версия ([Rust](https://static.rust-lang.org/dist/rust-1.0.0-i686-pc-windows-gnu.msi)
15 | и [Cargo](https://static.rust-lang.org/cargo-dist/cargo-nightly-i686-pc-windows-gnu.tar.gz)) или 64-х битная версия ([Rust](https://static.rust-lang.org/dist/rust-1.0.0-x86_64-pc-windows-gnu.msi) и [Cargo](https://static.rust-lang.org/cargo-dist/cargo-nightly-x86_64-pc-windows-gnu.tar.gz))
16 |
17 | Вы так же можете собрать Cargo из исходного кода.
18 |
19 | Чтобы убедиться, что установка прошла успешно, можно воспользоваться командой, которая выводит версию Cargo:
20 | ```shell
21 | $ cargo --version
22 | ```
23 |
24 | # Давайте начнем
25 |
26 | Чтобы создать новый проект при помощи Cargo, необходимо воспользоваться командой `cargo new`:
27 |
28 | ```shell
29 | $ cargo new hello_world --bin
30 | ```
31 |
32 | Мы передали аргумент `--bin`, потому что мы создаем исполняемую программу: если мы
33 | решим создать библиотеку, то этот аргумент необходимо убрать.
34 |
35 | Давайте посмотрим, что Cargo сгенерировал для нас:
36 |
37 | ```shell
38 | $ cd hello_world
39 | $ tree .
40 | .
41 | ├── Cargo.toml
42 | └── src
43 | └── main.rs
44 |
45 | 1 directory, 2 files
46 | ```
47 |
48 | Это все, что нам необходимо для начала. Первым делом давайте посмотрим, что за файл `Cargo.toml`:
49 |
50 | ```toml
51 | [package]
52 | name = "hello_world"
53 | version = "0.1.0"
54 | authors = ["Your Name "]
55 | ```
56 |
57 | Этот файл называется **манифестом** и содержит в себе все метаданные, которые необходимы Cargo,
58 | чтобы скомпилировать ваш проект.
59 |
60 | Вот, что мы найдем в файле `src/main.rs`:
61 |
62 | ```
63 | fn main() {
64 | println!("Hello, world!");
65 | }
66 | ```
67 |
68 | Cargo сгенерировал “hello world” для нас. Давайте скомпилируем его:
69 |
70 |
73 |
74 | А потом запустим:
75 |
76 | ```shell
77 | $ ./target/debug/hello_world
78 | Hello, world!
79 | ```
80 |
81 | Вы так же можете использовать `cargo run`, чтобы скомпилировать и запустить проект. Все за одну команду:
82 |
83 |
89 |
90 | # Двигаемся дальше
91 |
92 | Чтобы получить более подробную информацию о использование Cargo, ознакомьтесь с [Руководством по Cargo](guide.html)
93 |
--------------------------------------------------------------------------------
/src/doc/environment-variables.md:
--------------------------------------------------------------------------------
1 | % Environment Variables
2 |
3 | Cargo sets and reads a number of environment variables which your code can detect
4 | or override. Here is a list of the variables Cargo sets, organized by when it interacts
5 | with them:
6 |
7 | # Environment variables Cargo reads
8 |
9 | You can override these environment variables to change Cargo's behavior on your
10 | system:
11 |
12 | * `CARGO_HOME` - Cargo maintains a local cache of the registry index and of git
13 | checkouts of crates. By default these are stored under `$HOME/.cargo`, but
14 | this variable overrides the location of this directory. Once a crate is cached
15 | it is not removed by the clean command.
16 | * `CARGO_TARGET_DIR` - Location of where to place all generated artifacts,
17 | relative to the current working directory.
18 | * `RUSTC` - Instead of running `rustc`, Cargo will execute this specified
19 | compiler instead.
20 | * `RUSTDOC` - Instead of running `rustdoc`, Cargo will execute this specified
21 | `rustdoc` instance instead.
22 | * `RUSTFLAGS` - A space-separated list of custom flags to pass to all compiler
23 | invocations that Cargo performs. In contrast with `cargo rustc`, this is
24 | useful for passing a flag to *all* compiler instances.
25 |
26 | Note that Cargo will also read environment variables for `.cargo/config`
27 | configuration values, as described in [that documentation][config-env]
28 |
29 | [config-env]: config.html#environment-variables
30 |
31 | # Environment variables Cargo sets for crates
32 |
33 | Cargo exposes these environment variables to your crate when it is compiled. To get the
34 | value of any of these variables in a Rust program, do this:
35 |
36 | ```
37 | let version = env!("CARGO_PKG_VERSION");
38 | ```
39 |
40 | `version` will now contain the value of `CARGO_PKG_VERSION`.
41 |
42 | * `CARGO_MANIFEST_DIR` - The directory containing the manifest of your package.
43 | * `CARGO_PKG_VERSION` - The full version of your package.
44 | * `CARGO_PKG_VERSION_MAJOR` - The major version of your package.
45 | * `CARGO_PKG_VERSION_MINOR` - The minor version of your package.
46 | * `CARGO_PKG_VERSION_PATCH` - The patch version of your package.
47 | * `CARGO_PKG_VERSION_PRE` - The pre-release version of your package.
48 | * `CARGO_PKG_AUTHORS` - Colon seperated list of authors from the manifest of your package.
49 | * `CARGO_PKG_NAME` - The name of your package.
50 | * `CARGO_PKG_DESCRIPTION` - The description of your package.
51 | * `CARGO_PKG_HOMEPAGE` - The home page of your package.
52 |
53 | # Environment variables Cargo sets for build scripts
54 |
55 | Cargo sets several environment variables when build scripts are run. Because these variables
56 | are not yet set when the build script is compiled, the above example using `env!` won't work
57 | and instead you'll need to retrieve the values when the build script is run:
58 |
59 | ```
60 | use std::env;
61 | let out_dir = env::var("OUT_DIR").unwrap();
62 | ```
63 |
64 | `out_dir` will now contain the value of `OUT_DIR`.
65 |
66 | * `CARGO_MANIFEST_DIR` - The directory containing the manifest for the package
67 | being built (the package containing the build
68 | script). Also note that this is the value of the
69 | current working directory of the build script when it
70 | starts.
71 | * `CARGO_MANIFEST_LINKS` - the manifest `links` value.
72 | * `CARGO_FEATURE_` - For each activated feature of the package being
73 | built, this environment variable will be present
74 | where `` is the name of the feature uppercased
75 | and having `-` translated to `_`.
76 | * `OUT_DIR` - the folder in which all output should be placed. This folder is
77 | inside the build directory for the package being built, and it is
78 | unique for the package in question.
79 | * `TARGET` - the target triple that is being compiled for. Native code should be
80 | compiled for this triple. Some more information about target
81 | triples can be found in [clang’s own documentation][clang].
82 | * `HOST` - the host triple of the rust compiler.
83 | * `NUM_JOBS` - the parallelism specified as the top-level parallelism. This can
84 | be useful to pass a `-j` parameter to a system like `make`.
85 | * `OPT_LEVEL`, `DEBUG` - values of the corresponding variables for the
86 | profile currently being built.
87 | * `PROFILE` - name of the profile currently being built (see
88 | [profiles][profile]).
89 | * `DEP__` - For more information about this set of environment
90 | variables, see build script documentation about [`links`][links].
91 | * `RUSTC`, `RUSTDOC` - the compiler and documentation generator that Cargo has
92 | resolved to use, passed to the build script so it might
93 | use it as well.
94 |
95 | [links]: build-script.html#the-links-manifest-key
96 | [profile]: manifest.html#the-profile-sections
97 | [clang]:http://clang.llvm.org/docs/CrossCompilation.html#target-triple
98 |
--------------------------------------------------------------------------------
/src/doc/stylesheets/prism.css:
--------------------------------------------------------------------------------
1 | /* http://prismjs.com/download.html?themes=prism-twilight&languages=markup+css+clike+javascript */
2 | /**
3 | * prism.js Twilight theme
4 | * Based (more or less) on the Twilight theme originally of Textmate fame.
5 | * @author Remy Bach
6 | */
7 | code[class*="language-"],
8 | pre[class*="language-"] {
9 | color: white;
10 | direction: ltr;
11 | font-family: Consolas, Monaco, 'Andale Mono', monospace;
12 | text-align: left;
13 | text-shadow: 0 -.1em .2em black;
14 | white-space: pre;
15 | word-spacing: normal;
16 | word-break: normal;
17 | line-height: 1.5;
18 |
19 | -moz-tab-size: 4;
20 | -o-tab-size: 4;
21 | tab-size: 4;
22 |
23 | -webkit-hyphens: none;
24 | -moz-hyphens: none;
25 | -ms-hyphens: none;
26 | hyphens: none;
27 | }
28 |
29 | pre[class*="language-"],
30 | :not(pre) > code[class*="language-"] {
31 | background: hsl(0, 0%, 8%); /* #141414 */
32 | }
33 |
34 | /* Code blocks */
35 | pre[class*="language-"] {
36 | border-radius: .5em;
37 | border: .3em solid hsl(0, 0%, 33%); /* #282A2B */
38 | box-shadow: 1px 1px .5em black inset;
39 | margin: .5em 0;
40 | overflow: auto;
41 | padding: 1em;
42 | }
43 |
44 | pre[class*="language-"]::selection {
45 | /* Safari */
46 | background: hsl(200, 4%, 16%); /* #282A2B */
47 | }
48 |
49 | pre[class*="language-"]::selection {
50 | /* Firefox */
51 | background: hsl(200, 4%, 16%); /* #282A2B */
52 | }
53 |
54 | /* Text Selection colour */
55 | pre[class*="language-"]::-moz-selection, pre[class*="language-"] ::-moz-selection,
56 | code[class*="language-"]::-moz-selection, code[class*="language-"] ::-moz-selection {
57 | text-shadow: none;
58 | background: hsla(0, 0%, 93%, 0.15); /* #EDEDED */
59 | }
60 |
61 | pre[class*="language-"]::selection, pre[class*="language-"] ::selection,
62 | code[class*="language-"]::selection, code[class*="language-"] ::selection {
63 | text-shadow: none;
64 | background: hsla(0, 0%, 93%, 0.15); /* #EDEDED */
65 | }
66 |
67 | /* Inline code */
68 | :not(pre) > code[class*="language-"] {
69 | border-radius: .3em;
70 | border: .13em solid hsl(0, 0%, 33%); /* #545454 */
71 | box-shadow: 1px 1px .3em -.1em black inset;
72 | padding: .15em .2em .05em;
73 | }
74 |
75 | .token.comment,
76 | .token.prolog,
77 | .token.doctype,
78 | .token.cdata {
79 | color: hsl(0, 0%, 47%); /* #777777 */
80 | }
81 |
82 | .token.punctuation {
83 | opacity: .7;
84 | }
85 |
86 | .namespace {
87 | opacity: .7;
88 | }
89 |
90 | .token.tag,
91 | .token.boolean,
92 | .token.number,
93 | .token.deleted {
94 | color: hsl(14, 58%, 55%); /* #CF6A4C */
95 | }
96 |
97 | .token.keyword,
98 | .token.property,
99 | .token.selector,
100 | .token.constant,
101 | .token.symbol,
102 | .token.builtin {
103 | color: hsl(53, 89%, 79%); /* #F9EE98 */
104 | }
105 |
106 | .token.attr-name,
107 | .token.attr-value,
108 | .token.string,
109 | .token.char,
110 | .token.operator,
111 | .token.entity,
112 | .token.url,
113 | .language-css .token.string,
114 | .style .token.string,
115 | .token.variable,
116 | .token.inserted {
117 | color: hsl(76, 21%, 52%); /* #8F9D6A */
118 | }
119 |
120 | .token.atrule {
121 | color: hsl(218, 22%, 55%); /* #7587A6 */
122 | }
123 |
124 | .token.regex,
125 | .token.important {
126 | color: hsl(42, 75%, 65%); /* #E9C062 */
127 | }
128 |
129 | .token.important {
130 | font-weight: bold;
131 | }
132 |
133 | .token.entity {
134 | cursor: help;
135 | }
136 |
137 | pre[data-line] {
138 | padding: 1em 0 1em 3em;
139 | position: relative;
140 | }
141 |
142 | /* Markup */
143 | .language-markup .token.tag,
144 | .language-markup .token.attr-name,
145 | .language-markup .token.punctuation {
146 | color: hsl(33, 33%, 52%); /* #AC885B */
147 | }
148 |
149 | /* Make the tokens sit above the line highlight so the colours don't look faded. */
150 | .token {
151 | position: relative;
152 | z-index: 1;
153 | }
154 |
155 | .line-highlight {
156 | background: -moz-linear-gradient(left, hsla(0, 0%, 33%, .1) 70%, hsla(0, 0%, 33%, 0)); /* #545454 */
157 | background: -o-linear-gradient(left, hsla(0, 0%, 33%, .1) 70%, hsla(0, 0%, 33%, 0)); /* #545454 */
158 | background: -webkit-linear-gradient(left, hsla(0, 0%, 33%, .1) 70%, hsla(0, 0%, 33%, 0)); /* #545454 */
159 | background: hsla(0, 0%, 33%, 0.25); /* #545454 */
160 | background: linear-gradient(left, hsla(0, 0%, 33%, .1) 70%, hsla(0, 0%, 33%, 0)); /* #545454 */
161 | border-bottom: 1px dashed hsl(0, 0%, 33%); /* #545454 */
162 | border-top: 1px dashed hsl(0, 0%, 33%); /* #545454 */
163 | left: 0;
164 | line-height: inherit;
165 | margin-top: 0.75em; /* Same as .prism’s padding-top */
166 | padding: inherit 0;
167 | pointer-events: none;
168 | position: absolute;
169 | right: 0;
170 | white-space: pre;
171 | z-index: 0;
172 | }
173 |
174 | .line-highlight:before,
175 | .line-highlight[data-end]:after {
176 | background-color: hsl(215, 15%, 59%); /* #8794A6 */
177 | border-radius: 999px;
178 | box-shadow: 0 1px white;
179 | color: hsl(24, 20%, 95%); /* #F5F2F0 */
180 | content: attr(data-start);
181 | font: bold 65%/1.5 sans-serif;
182 | left: .6em;
183 | min-width: 1em;
184 | padding: 0 .5em;
185 | position: absolute;
186 | text-align: center;
187 | text-shadow: none;
188 | top: .4em;
189 | vertical-align: .3em;
190 | }
191 |
192 | .line-highlight[data-end]:after {
193 | bottom: .4em;
194 | content: attr(data-end);
195 | top: auto;
196 | }
197 |
198 |
--------------------------------------------------------------------------------
/src/doc/config.md:
--------------------------------------------------------------------------------
1 | % Настройка Cargo
2 |
3 | В данном документе мы расскажем вам, как работает настройка Cargo, используя доступные для
4 | конфигурации ключи и настройки. Для настройке проекта с помощью манифест файла, загляните на
5 | страницу [формат манифеста](manifest.html).
6 |
7 | # Иерархическая структура
8 |
9 | Cargo позволяет делать настройки как для локальных проектов, так и для
10 | всех (как git, например). Cargo также расширяет эту возможность используя иерархическую
11 | структуру. Если, например, Cargo будет вызван в директории `/home/foo/bar/baz`, то поиск
12 | конфигурационных файлов будет осуществлен по следующим директориям:
13 |
14 | * `/home/foo/bar/baz/.cargo/config`
15 | * `/home/foo/bar/.cargo/config`
16 | * `/home/foo/.cargo/config`
17 | * `/home/.cargo/config`
18 | * `/.cargo/config`
19 |
20 | Благодаря такой структуре вы можете указывать конфигурацию для каждого проекта отдельно, и даже,
21 | возможно, добавлять его в вашу систему контроля версий. Вы также можете указать
22 | нужную вам конфигурацию в файле в домашней директории.
23 |
24 | # Формат конфигурационного файла
25 |
26 | Все конфигурационные файлы хранятся в [TOML формате][toml] (как манифесты),
27 | в простом формате ключ-значение, которые хранятся внутри секций (таблиц), а потом будут объединены.
28 |
29 | [toml]: https://github.com/toml-lang/toml
30 |
31 | # Ключи для конфигурации
32 |
33 | Все последующие ключи являются опциональными. Также стоит ответить, что мы указывали
34 | значения по умолчанию для каждого значения.
35 |
36 | Ключи для значений, которые указывают на определенную программу, могут быть в формате абсолютного
37 | пути, относительного, а также можно просто указать название программы. Абсолютные пути и
38 | название программ используются как есть. Относительные пути используются исходя из родительской
39 | директории, в которой расположена директория `.cargo`, в которой находится конфигурационный файл.
40 |
41 | ```toml
42 | # Массив путей к локальным репозиториям, которые будут переопределены в качестве
43 | # зависимостей. Для более подробной информации смотрите документ Specifying Dependencies.
44 | paths = ["/path/to/override"]
45 |
46 | [cargo-new]
47 | # Настройки для имени/email, которые будут помещены в блок `authors` в новых Cargo.toml
48 | # Если эти параметры не указаны, будут взяты параметры из конфигурации `git`. А, если и их нет
49 | # запишутся `$USER` и `$EMAIL`.
50 | name = "..."
51 | email = "..."
52 |
53 | # По умолчанию команда `cargo new` создан новый Git репозиторий. Это значение может быть
54 | # изменено на `hg`, тогда будет создан Mercurial репозиторий, или `none`, чтобы отключить
55 | # данный функционал.
56 | vcs = "none"
57 |
58 | # Для следующего раздела, $triple относится к любой возможной целевой платформой,
59 | # не к строкову литералу "$triple", и будет применяться каждый раз, когда будет сборка
60 | # для целевой платформы.
61 | [target]
62 | # Для сборок Cargo, для которых не указан параметр --target, будет использован компоновщик
63 | # переданный в rustc (с помощью `-C linker=`). По умолчанию этот флаг не передан
64 | # как параметр компилятора.
65 | linker = ".."
66 |
67 | [target.$triple]
68 | # Этот раздел похож на раздел, который был описан выше, но тут указывается конкретная
69 | # целевая платформа, которая будет скомпилирована.
70 | linker = ".."
71 | # пользовательские настройки будут переданы в компилятор, каждый раз когда будет $triple
72 | # вызвана компиляция для целевой платформы.
73 | # этот параметр переопределит build.rustflags, если он указан
74 | rustflags = ["..", ".."]
75 |
76 | # Настройки для реестра
77 | [registry]
78 | index = "..." # Ссылка для индекса реестра (по умолчанию - центральный репозиторий)
79 | token = "..." # Ключ доступа (можно найти на сайте центрального репозитория)
80 |
81 | [http]
82 | proxy = "..." # HTTP прокси. Используется для HTTP запросов (по умолчанию не указан)
83 | timeout = 60000 # Таймаут для каждого HTTP запроса, в миллисекундах
84 | cainfo = "cert.pem" # Путь до ключа Центра Сертификации (опционально)
85 |
86 | [build]
87 | jobs = 1 # количество параллельно выполняемых заданий, по умолчанию -
88 | # количество ЦП
89 | rustc = "rustc" # компилятор rust
90 | rustdoc = "rustdoc" # инструмент генерации документации
91 | target = "triple" # build for the target triple
92 | target-dir = "target" # путь к директории, в которой будет скомпилированный проект
93 | rustflags = ["..", ".."] # настройки, которые будут переданы компилятору
94 |
95 | [term]
96 | verbose = false # предоставлять ли cargo развернутый вывод
97 | color = 'auto' # предоставлять ли cargo цветной вывод
98 |
99 | # Конфигурация сети
100 | [net]
101 | retry = 2 # сколько раз будет вызвана попытка повторной отправки сигнала
102 |
103 | # Псевдонимы для команд Cargo. Первые 3 псевдонима встроены.
104 | # Если вы хотите передать параметры в псевдоним, в которых есть пробелы, то используйте список.
105 | [alias]
106 | b = "build"
107 | t = "test"
108 | r = "run"
109 | rr = "run --release"
110 | space_example = ["run", "--release", "--", "\"command list\""]
111 | ```
112 |
113 | # Переменные среды
114 |
115 | Cargo также можно настроить с помощью переменных среды, в дополнение к
116 | TOML конфигурационным файлам. Для каждой настройки `foo.bar`
117 | есть переменная среды `CARGO_FOO_BAR` для которой также можно указать значение.
118 | Например, настройка `build.jobs` может быть указана с помощью переменной среды `CARGO_BUILD_JOBS`.
119 |
120 | Приоритет переменных среды выше, чем приоритет значений в TOML конфигурациях. В данный момент
121 | в качестве значений для переменных среды можно указывать только целочисленные, логические и
122 | строковые.
123 |
124 | В дополнение к вышеперечисленному, Cargo работает и с другими [переменными среды][env].
125 |
126 | [env]: environment-variables.html
127 |
--------------------------------------------------------------------------------
/src/doc/source-replacement.md:
--------------------------------------------------------------------------------
1 | % Replacing sources
2 |
3 | Cargo supports the ability to **replace one source with another** to express
4 | strategies along the lines of mirrors or vendoring dependencies. Configuration
5 | is currently done through the [`.cargo/config` configuration][config] mechanism,
6 | like so:
7 |
8 | [config]: config.html
9 |
10 | ```toml
11 | # The `source` table is where all keys related to source-replacement
12 | # are stored.
13 | [source]
14 |
15 | # Under the `source` table are a number of other tables whose keys are a
16 | # name for the relevant source. For example this section defines a new
17 | # source, called `my-awesome-source`, which comes from a directory
18 | # located at `vendor` relative to the directory containing this `.cargo/config`
19 | # file
20 | [source.my-awesome-source]
21 | directory = "vendor"
22 |
23 | # The crates.io default source for crates is available under the name
24 | # "crates-io", and here we use the `replace-with` key to indicate that it's
25 | # replaced with our source above.
26 | [source.crates-io]
27 | replace-with = "my-awesome-source"
28 | ```
29 |
30 | With this configuration Cargo attempts to look up all crates in the directory
31 | "vendor" rather than querying the online registry at crates.io. Using source
32 | replacement Cargo can express:
33 |
34 | * Vendoring - custom sources can be defined which represent crates on the local
35 | filesystem. These sources are subsets of the source that they're replacing and
36 | can be checked into projects if necessary.
37 |
38 | * Mirroring - sources can be replaced with an equivalent version which acts as a
39 | cache for crates.io itself.
40 |
41 | Cargo has a core assumption about source replacement that the source code is
42 | exactly the same from both sources. In our above example Cargo assumes that all
43 | of the crates coming from `my-awesome-source` are the exact same as the copies
44 | from `crates-io`. Note that this also means that `my-awesome-source` is not
45 | allowed to have crates which are not present in the `crates-io` source.
46 |
47 | As a consequence, source replacement is not appropriate for situations such as
48 | patching a dependency or a private registry. Cargo supports patching
49 | dependencies through the usage of [the `[replace]` key][replace-section], and
50 | private registry support is planned for a future version of Cargo.
51 |
52 | [replace-section]: manifest.html#the-replace-section
53 |
54 | ## Configuration
55 |
56 | Configuration of replacement sources is done through [`.cargo/config`][config]
57 | and the full set of available keys are:
58 |
59 | ```toml
60 | # Each source has its own table where the key is the name of the source
61 | [source.the-source-name]
62 |
63 | # Indicate that `the-source-name` will be replaced with `another-source`,
64 | # defined elsewhere
65 | replace-with = "another-source"
66 |
67 | # Available kinds of sources that can be specified (described below)
68 | registry = "https://example.com/path/to/index"
69 | local-registry = "path/to/registry"
70 | directory = "path/to/vendor"
71 | ```
72 |
73 | The `crates-io` represents the crates.io online registry (default source of
74 | crates) and can be replaced with:
75 |
76 | ```toml
77 | [source.crates-io]
78 | replace-with = 'another-source'
79 | ```
80 |
81 | ## Registry Sources
82 |
83 | A "registry source" is one that is the same as crates.io itself. That is, it has
84 | an index served in a git repository which matches the format of the
85 | [crates.io index](https://github.com/rust-lang/crates.io-index). That repository
86 | then has configuration indicating where to download crates from.
87 |
88 | Currently there is not an already-available project for setting up a mirror of
89 | crates.io. Stay tuned though!
90 |
91 | ## Local Registry Sources
92 |
93 | A "local registry source" is intended to be a subset of another registry
94 | source, but available on the local filesystem (aka vendoring). Local registries
95 | are downloaded ahead of time, typically sync'd with a `Cargo.lock`, and are
96 | made up of a set of `*.crate` files and an index like the normal registry is.
97 |
98 | The primary way to manage and crate local registry sources is through the
99 | [`cargo-local-registry`][cargo-local-registry] subcommand, available on
100 | crates.io and can be installed with `cargo install cargo-local-registry`.
101 |
102 | [cargo-local-registry]: https://crates.io/crates/cargo-local-registry
103 |
104 | Local registries are contained within one directory and contain a number of
105 | `*.crate` files downloaded from crates.io as well as an `index` directory with
106 | the same format as the crates.io-index project (populated with just entries for
107 | the crates that are present).
108 |
109 | ## Directory Sources
110 |
111 | A "directory source" is similar to a local registry source where it contains a
112 | number of crates available on the local filesystem, suitable for vendoring
113 | dependencies. Also like local registries, directory sources can primarily be
114 | managed by an external subcommand, [`cargo-vendor`][cargo-vendor], which can be
115 | installed with `cargo install cargo-vendor`.
116 |
117 | [cargo-vendor]: https://crates.io/crates/cargo-vendor
118 |
119 | Directory sources are distinct from local registries though in that they contain
120 | the unpacked version of `*.crate` files, making it more suitable in some
121 | situations to check everything into source control. A directory source is just a
122 | directory containing a number of other directories which contain the source code
123 | for crates (the unpacked version of `*.crate` files). Currently no restriction
124 | is placed on the name of each directory.
125 |
126 | Each crate in a directory source also has an associated metadata file indicating
127 | the checksum of each file in the crate to protect against accidental
128 | modifications.
129 |
--------------------------------------------------------------------------------
/src/doc/javascripts/prism.js:
--------------------------------------------------------------------------------
1 | /* http://prismjs.com/download.html?themes=prism&languages=markup+css+clike+javascript */
2 | self="undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{};var Prism=function(){var e=/\blang(?:uage)?-(?!\*)(\w+)\b/i,t=self.Prism={util:{encode:function(e){return e instanceof n?new n(e.type,t.util.encode(e.content),e.alias):"Array"===t.util.type(e)?e.map(t.util.encode):e.replace(/&/g,"&").replace(/e.length)break e;if(!(d instanceof a)){c.lastIndex=0;var m=c.exec(d);if(m){u&&(f=m[1].length);var y=m.index-1+f,m=m[0].slice(f),v=m.length,k=y+v,b=d.slice(0,y+1),w=d.slice(k+1),N=[p,1];b&&N.push(b);var O=new a(l,g?t.tokenize(m,g):m,h);N.push(O),w&&N.push(w),Array.prototype.splice.apply(r,N)}}}}}return r},hooks:{all:{},add:function(e,n){var a=t.hooks.all;a[e]=a[e]||[],a[e].push(n)},run:function(e,n){var a=t.hooks.all[e];if(a&&a.length)for(var r,i=0;r=a[i++];)r(n)}}},n=t.Token=function(e,t,n){this.type=e,this.content=t,this.alias=n};if(n.stringify=function(e,a,r){if("string"==typeof e)return e;if("[object Array]"==Object.prototype.toString.call(e))return e.map(function(t){return n.stringify(t,a,e)}).join("");var i={type:e.type,content:n.stringify(e.content,a,r),tag:"span",classes:["token",e.type],attributes:{},language:a,parent:r};if("comment"==i.type&&(i.attributes.spellcheck="true"),e.alias){var l="Array"===t.util.type(e.alias)?e.alias:[e.alias];Array.prototype.push.apply(i.classes,l)}t.hooks.run("wrap",i);var o="";for(var s in i.attributes)o+=s+'="'+(i.attributes[s]||"")+'"';return"<"+i.tag+' class="'+i.classes.join(" ")+'" '+o+">"+i.content+""+i.tag+">"},!self.document)return self.addEventListener?(self.addEventListener("message",function(e){var n=JSON.parse(e.data),a=n.language,r=n.code;self.postMessage(JSON.stringify(t.util.encode(t.tokenize(r,t.languages[a])))),self.close()},!1),self.Prism):self.Prism;var a=document.getElementsByTagName("script");return a=a[a.length-1],a&&(t.filename=a.src,document.addEventListener&&!a.hasAttribute("data-manual")&&document.addEventListener("DOMContentLoaded",t.highlightAll)),self.Prism}();"undefined"!=typeof module&&module.exports&&(module.exports=Prism);;
3 | Prism.languages.markup={comment://g,prolog:/<\?.+?\?>/,doctype://,cdata://i,tag:{pattern:/<\/?[\w:-]+\s*(?:\s+[\w:-]+(?:=(?:("|')(\\?[\w\W])*?\1|[^\s'">=]+))?\s*)*\/?>/gi,inside:{tag:{pattern:/^<\/?[\w:-]+/i,inside:{punctuation:/^<\/?/,namespace:/^[\w-]+?:/}},"attr-value":{pattern:/=(?:('|")[\w\W]*?(\1)|[^\s>]+)/gi,inside:{punctuation:/=|>|"/g}},punctuation:/\/?>/g,"attr-name":{pattern:/[\w:-]+/g,inside:{namespace:/^[\w-]+?:/}}}},entity:/\?[\da-z]{1,8};/gi},Prism.hooks.add("wrap",function(t){"entity"===t.type&&(t.attributes.title=t.content.replace(/&/,"&"))});;
4 | Prism.languages.css={comment:/\/\*[\w\W]*?\*\//g,atrule:{pattern:/@[\w-]+?.*?(;|(?=\s*{))/gi,inside:{punctuation:/[;:]/g}},url:/url\((["']?).*?\1\)/gi,selector:/[^\{\}\s][^\{\};]*(?=\s*\{)/g,property:/(\b|\B)[\w-]+(?=\s*:)/gi,string:/("|')(\\?.)*?\1/g,important:/\B!important\b/gi,punctuation:/[\{\};:]/g,"function":/[-a-z0-9]+(?=\()/gi},Prism.languages.markup&&Prism.languages.insertBefore("markup","tag",{style:{pattern:/