@@ -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.
@@ -221,17 +224,17 @@ Other git hosts may provide something equivalent under a different naming scheme
221
224
222
225
``` toml
223
226
# .git suffix can be omitted if the host accepts such URLs - both examples work the same
224
- regex = { git = " https://github.com/rust-lang/regex" }
225
- regex = { git = " https://github.com/rust-lang/regex.git" }
227
+ regex = { git = " https://github.com/rust-lang/regex" }
228
+ regex = { git = " https://github.com/rust-lang/regex.git" }
226
229
227
230
# a commit with a particular tag
228
- regex = { git = " https://github.com/rust-lang/regex" , tag = " 1.10.3" }
231
+ regex = { git = " https://github.com/rust-lang/regex.git " , tag = " 1.10.3" }
229
232
230
233
# a commit by its SHA1 hash
231
- regex = { git = " https://github.com/rust-lang/regex" , rev = " 0c0990399270277832fbb5b91a1fa118e6f63dba" }
234
+ regex = { git = " https://github.com/rust-lang/regex.git " , rev = " 0c0990399270277832fbb5b91a1fa118e6f63dba" }
232
235
233
236
# HEAD commit of PR 493
234
- regex = { git = " https://github.com/rust-lang/regex" , rev = " refs/pull/493/head" }
237
+ regex = { git = " https://github.com/rust-lang/regex.git " , rev = " refs/pull/493/head" }
235
238
236
239
# INVALID EXAMPLES
237
240
@@ -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.
@@ -259,7 +262,7 @@ is compatible with `version = "1.10.3"`:
259
262
260
263
``` toml
261
264
[dependencies ]
262
- regex = { version = " 1.10.3" , git = " https://github.com/rust-lang/regex" , branch = " next" }
265
+ regex = { version = " 1.10.3" , git = " https://github.com/rust-lang/regex.git " , branch = " next" }
263
266
```
264
267
265
268
` version ` , ` git ` , and ` path ` keys are considered separate locations for resolving the dependency.
@@ -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,40 +306,40 @@ 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.
310
- For example, if ` cpp ` and ` cpp_common ` are members of a locally cloned ` rust-cpp ` repo,
311
- they have to be referred to by the full path:
313
+ For example, if ` regex-lite ` and ` regex-syntax ` are members of a
314
+ locally cloned ` rust-lang/regex ` repo, they have to be referred to by the full path:
312
315
313
316
``` toml
314
317
# git key accepts the repo root URL and Cargo traverses the tree to find the crate
315
318
[dependencies ]
316
- cpp = { git = " https://github.com/mystor/ rust-cpp " }
317
- cpp_common = { git = " https://github.com/mystor/ rust-cpp " }
319
+ regex-lite = { git = " https://github.com/rust-lang/regex.git " }
320
+ regex-syntax = { git = " https://github.com/rust-lang/regex.git " }
318
321
319
322
# path key requires the member name to be included in the local path
320
323
[dependencies ]
321
- cpp = { path = " ../rust-cpp/cpp " }
322
- cpp_common = { path = " ../rust-cpp/cpp_common " }
324
+ regex-lite = { path = " ../regex/regex-lite " }
325
+ regex-syntax = { path = " ../regex/regex-syntax " }
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] .
329
332
330
- If we wanted to publish our ` hello_world ` crate, we
331
- would need to publish a version of ` hello_utils ` to [ crates.io]
332
- as a separate crate and specify its version in the dependencies line of ` hello_world ` :
333
+ If we wanted to publish our ` hello_world ` crate,
334
+ we would need to publish a version of ` hello_utils ` to [ crates.io] as a separate crate
335
+ and specify its version in the dependencies line of ` hello_world ` :
333
336
334
337
``` toml
335
338
[dependencies ]
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