@@ -51,7 +51,9 @@ versions before 1.0.0. While SemVer says there is no compatibility before
51
51
and ` x > 0 ` .
52
52
53
53
It is possible to further tweak the logic for selecting compatible versions
54
- using special operators as described in the following section.
54
+ using special operators as described in the [ Version requirement syntax] ( #version-requirement-syntax ) section.
55
+
56
+ Use the default version requirement strategy, e.g. ` log = "1.2.3" ` where possible to maximize compatibility.
55
57
56
58
## Version requirement syntax
57
59
@@ -184,19 +186,20 @@ you need to specify is the location of the repository with the `git` key:
184
186
regex = { git = " https://github.com/rust-lang/regex.git" }
185
187
```
186
188
187
- Cargo fetches the ` git ` repository at that location, then looks for
188
- ` Cargo.toml ` file for the requested crate anywhere inside the ` git ` repository.
189
- For example, ` cpp ` and ` cpp_common ` are members of ` rust-cpp ` repo
190
- and can be referred to by the repo's root URL (` https://github.com/mystor/rust-cpp ` ).
189
+ Cargo fetches the ` git ` repository at that location and traverses the file tree to find
190
+ ` Cargo.toml ` file for the requested crate anywhere inside the ` git ` repository.
191
+ For example, ` regex-lite ` and ` regex-syntax ` are members of ` rust-lang/regex ` repo
192
+ and can be referred to by the repo's root URL (` https://github.com/rust-lang/regex.git ` )
193
+ regardless of where in the file tree they reside.
191
194
192
195
``` toml
193
- cpp = { git = " https://github.com/mystor/ rust-cpp " }
194
- cpp_common = { git = " https://github.com/mystor/ rust-cpp " }
196
+ regex-lite = { git = " https://github.com/rust-lang/regex.git " }
197
+ regex-syntax = { git = " https://github.com/rust-lang/regex.git " }
195
198
```
196
199
197
- The above rule does not apply to local paths specified via ` path ` attribute .
200
+ The above rule does not apply to [ ` path ` dependencies ] ( #specifying-path-dependencies ) .
198
201
199
- #### Choice of commit
202
+ ### Choice of commit
200
203
201
204
Cargo assumes that we intend to use the latest commit on the default branch to build
202
205
our package if we only specify the repo URL, as in the examples above.
@@ -245,7 +248,7 @@ regex = { git = "https://github.com/rust-lang/regex.git#4c59b70", path = "../reg
245
248
Cargo locks the commits of ` git ` dependencies in ` Cargo.lock ` file at the time of their addition
246
249
and checks for updates only when you run ` cargo update ` command.
247
250
248
- #### The role of _ version _ key
251
+ ### The role of the ` version ` key
249
252
250
253
The ` version ` key always implies that the package is available in a registry,
251
254
regardless of the presence of ` git ` or ` path ` keys.
@@ -271,7 +274,7 @@ See [Multiple locations](#multiple-locations) section below for detailed explana
271
274
> locations] ( #multiple-locations ) section for a fallback alternative for ` git `
272
275
> and ` path ` dependencies.
273
276
274
- #### Accessing private Git repositories
277
+ ### Accessing private Git repositories
275
278
276
279
See [ Git Authentication] ( ../appendix/git-authentication.md ) for help with Git authentication for private repos.
277
280
@@ -303,7 +306,7 @@ in the `hello_utils` folder, relative to the `Cargo.toml` file it’s written in
303
306
The next ` cargo build ` will automatically build ` hello_utils ` and
304
307
all of its dependencies.
305
308
306
- #### No local path traversal
309
+ ### No local path traversal
307
310
308
311
The local paths must point to the exact folder with the dependency's ` Cargo.toml ` .
309
312
Unlike with ` git ` dependencies, Cargo does not traverse local paths.
@@ -322,7 +325,7 @@ cpp = { path = "../rust-cpp/cpp" }
322
325
cpp_common = { path = " ../rust-cpp/cpp_common" }
323
326
```
324
327
325
- #### Local paths in published crates
328
+ ### Local paths in published crates
326
329
327
330
Crates that use dependencies specified with only a path are not
328
331
permitted on [ crates.io] .
@@ -336,7 +339,7 @@ as a separate crate and specify its version in the dependencies line of `hello_w
336
339
hello_utils = { path = " hello_utils" , version = " 0.1.0" }
337
340
```
338
341
339
- The use of ` path ` and ` version ` keys together is explained in the next section.
342
+ The use of ` path ` and ` version ` keys together is explained in the [ Multiple locations ] ( #multiple-locations ) section.
340
343
341
344
> ** Note** : [ crates.io] does not allow packages to be published with
342
345
> dependencies on code outside of [ crates.io] , except for [ dev-dependencies] .
0 commit comments