@@ -51,7 +51,9 @@ versions before 1.0.0. While SemVer says there is no compatibility before
5151and ` x > 0 ` .
5252
5353It 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.
5557
5658## Version requirement syntax
5759
@@ -184,19 +186,20 @@ you need to specify is the location of the repository with the `git` key:
184186regex = { git = " https://github.com/rust-lang/regex.git" }
185187```
186188
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.
191194
192195``` 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 " }
195198```
196199
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 ) .
198201
199- #### Choice of commit
202+ ### Choice of commit
200203
201204Cargo assumes that we intend to use the latest commit on the default branch to build
202205our 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
221224
222225``` toml
223226# .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" }
226229
227230# 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" }
229232
230233# 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" }
232235
233236# 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" }
235238
236239# INVALID EXAMPLES
237240
@@ -245,7 +248,7 @@ regex = { git = "https://github.com/rust-lang/regex.git#4c59b70", path = "../reg
245248Cargo locks the commits of ` git ` dependencies in ` Cargo.lock ` file at the time of their addition
246249and checks for updates only when you run ` cargo update ` command.
247250
248- #### The role of _ version _ key
251+ ### The role of the ` version ` key
249252
250253The ` version ` key always implies that the package is available in a registry,
251254regardless of the presence of ` git ` or ` path ` keys.
@@ -259,7 +262,7 @@ is compatible with `version = "1.10.3"`:
259262
260263``` toml
261264[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" }
263266```
264267
265268` 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
271274> locations] ( #multiple-locations ) section for a fallback alternative for ` git `
272275> and ` path ` dependencies.
273276
274- #### Accessing private Git repositories
277+ ### Accessing private Git repositories
275278
276279See [ Git Authentication] ( ../appendix/git-authentication.md ) for help with Git authentication for private repos.
277280
@@ -303,40 +306,40 @@ in the `hello_utils` folder, relative to the `Cargo.toml` file it’s written in
303306The next ` cargo build ` will automatically build ` hello_utils ` and
304307all of its dependencies.
305308
306- #### No local path traversal
309+ ### No local path traversal
307310
308311The local paths must point to the exact folder with the dependency's ` Cargo.toml ` .
309312Unlike 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:
312315
313316``` toml
314317# git key accepts the repo root URL and Cargo traverses the tree to find the crate
315318[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 " }
318321
319322# path key requires the member name to be included in the local path
320323[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 " }
323326```
324327
325- #### Local paths in published crates
328+ ### Local paths in published crates
326329
327330Crates that use dependencies specified with only a path are not
328331permitted on [ crates.io] .
329332
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 ` :
333336
334337``` toml
335338[dependencies ]
336339hello_utils = { path = " hello_utils" , version = " 0.1.0" }
337340```
338341
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.
340343
341344> ** Note** : [ crates.io] does not allow packages to be published with
342345> dependencies on code outside of [ crates.io] , except for [ dev-dependencies] .
0 commit comments