mirror of
https://github.com/rust-lang/cargo
synced 2024-09-13 21:11:44 +00:00
feat(cargo-util-schemas): TryFrom<PartialVersion>
for RustVersion
This commit is contained in:
parent
10b8e7bdac
commit
7b0919399d
|
@ -1417,6 +1417,14 @@ impl std::str::FromStr for RustVersion {
|
||||||
fn from_str(value: &str) -> Result<Self, Self::Err> {
|
fn from_str(value: &str) -> Result<Self, Self::Err> {
|
||||||
let partial = value.parse::<PartialVersion>();
|
let partial = value.parse::<PartialVersion>();
|
||||||
let partial = partial.map_err(RustVersionErrorKind::PartialVersion)?;
|
let partial = partial.map_err(RustVersionErrorKind::PartialVersion)?;
|
||||||
|
partial.try_into()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TryFrom<PartialVersion> for RustVersion {
|
||||||
|
type Error = RustVersionError;
|
||||||
|
|
||||||
|
fn try_from(partial: PartialVersion) -> Result<Self, Self::Error> {
|
||||||
if partial.pre.is_some() {
|
if partial.pre.is_some() {
|
||||||
return Err(RustVersionErrorKind::Prerelease.into());
|
return Err(RustVersionErrorKind::Prerelease.into());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue