mirror of
https://github.com/rust-lang/cargo
synced 2024-08-27 19:29:21 +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> {
|
||||
let partial = value.parse::<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() {
|
||||
return Err(RustVersionErrorKind::Prerelease.into());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue