Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug fix
Browse files Browse the repository at this point in the history
Zekun Wang committed May 23, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 9d2ae7c commit e406711
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions third_party/move/tools/move-package/src/source_package/std_lib.rs
Original file line number Diff line number Diff line change
@@ -69,25 +69,30 @@ impl StdLib {
pub enum StdVersion {
Mainnet,
Testnet,
Dev,
Devnet,
}

impl StdVersion {
const MAINNET: &'static str = "mainnet";
const TESTNET: &'static str = "testnet";
const DEVNET: &'static str = "devnet";


/// Returns the rev name of the standard library version.
pub fn rev(&self) -> &'static str {
match self {
StdVersion::Mainnet => "mainnet",
StdVersion::Testnet => "testnet",
StdVersion::Dev => "dev",
StdVersion::Mainnet => StdVersion::MAINNET,
StdVersion::Testnet => StdVersion::TESTNET,
StdVersion::Devnet => StdVersion::DEVNET,
}
}

/// Returns the standard library version from the given rev name, or `None` if the string is not a standard library version.
pub fn from_rev(version: &str) -> Option<StdVersion> {
match version {
"mainnet" => Some(Self::Mainnet),
"testnet" => Some(Self::Testnet),
"dev" => Some(Self::Dev),
StdVersion::MAINNET => Some(Self::Mainnet),
StdVersion::TESTNET => Some(Self::Testnet),
StdVersion::DEVNET => Some(Self::Devnet),
_ => None,
}
}

0 comments on commit e406711

Please sign in to comment.