在 Cargo 中指定依赖版本的语法是什么?
What is the syntax for specifying dependency versions in Cargo?
到目前为止我已经看过三个...
[dependencies]
crate = "1.0.0" # I think this is an exact version match
crate = "^1.0.0" # I think this means "use that latest 1.x.x"
crate = "*" # I think this means "use the latest"
我很想知道如何使用依赖列表。最好有一个权威来源来记录依赖项的不同语法。
参见crates.io
documentation page on "Specifying Dependencies"。总结:
无或插入符号 (^
) 表示 "at least this version, until the next incompatible version"。
波浪号 (~
) 表示 "at least this version, until (but excluding) the next minor/major release"。也就是说,~1.2.3
将接受 1.2.<em>X</em>
其中 X
是至少3个,~1.2
会接受1.2.*
,~1
会接受1.*.*
.
通配符 (*
) 表示 "anything that looks like this"。也就是说,1.2.*
将接受 1.2.<em>anything</em>
(1.2.0
, 1.2.7-beta
, 1.2.93-dev.foo
, 等等但不是 1.3.0
).
不等式(>=
、>
、<
、=
)意味着显而易见的:Cargo 使用的版本必须满足给定的不等式。
到目前为止我已经看过三个...
[dependencies]
crate = "1.0.0" # I think this is an exact version match
crate = "^1.0.0" # I think this means "use that latest 1.x.x"
crate = "*" # I think this means "use the latest"
我很想知道如何使用依赖列表。最好有一个权威来源来记录依赖项的不同语法。
参见crates.io
documentation page on "Specifying Dependencies"。总结:
无或插入符号 (
^
) 表示 "at least this version, until the next incompatible version"。波浪号 (
~
) 表示 "at least this version, until (but excluding) the next minor/major release"。也就是说,~1.2.3
将接受1.2.<em>X</em>
其中X
是至少3个,~1.2
会接受1.2.*
,~1
会接受1.*.*
.通配符 (
*
) 表示 "anything that looks like this"。也就是说,1.2.*
将接受1.2.<em>anything</em>
(1.2.0
,1.2.7-beta
,1.2.93-dev.foo
, 等等但不是1.3.0
).不等式(
>=
、>
、<
、=
)意味着显而易见的:Cargo 使用的版本必须满足给定的不等式。