diff options
Diffstat (limited to 'src/librustpkg/crate_id.rs')
| -rw-r--r-- | src/librustpkg/crate_id.rs | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/librustpkg/crate_id.rs b/src/librustpkg/crate_id.rs index bd9a75bad69..9415e850e98 100644 --- a/src/librustpkg/crate_id.rs +++ b/src/librustpkg/crate_id.rs @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use version::{Version, NoVersion, ExactRevision}; use std::hash::Streaming; use std::hash; use syntax::crateid; @@ -32,7 +31,7 @@ pub struct CrateId { /// of package IDs whose short names aren't valid Rust identifiers. short_name: ~str, /// The requested package version. - version: Version + version: Option<~str> } impl Eq for CrateId { @@ -42,6 +41,13 @@ impl Eq for CrateId { } impl CrateId { + pub fn get_version<'a>(&'a self) -> &'a str { + match self.version { + Some(ref ver) => ver.as_slice(), + None => "0.0" + } + } + pub fn new(s: &str) -> CrateId { use conditions::bad_pkg_id::cond; @@ -52,10 +58,6 @@ impl CrateId { let raw_crateid = raw_crateid.unwrap(); let crateid::CrateId { path, name, version } = raw_crateid; let path = Path::new(path); - let version = match version { - Some(v) => ExactRevision(v), - None => NoVersion, - }; CrateId { path: path, @@ -67,13 +69,13 @@ impl CrateId { pub fn hash(&self) -> ~str { // FIXME (#9639): hash should take a &[u8] so we can hash the real path self.path.display().with_str(|s| { - let vers = self.version.to_str(); + let vers = self.get_version(); format!("{}-{}-{}", s, hash(s + vers), vers) }) } pub fn short_name_with_version(&self) -> ~str { - format!("{}{}", self.short_name, self.version.to_str()) + format!("{}-{}", self.short_name, self.get_version()) } /// True if the ID has multiple components @@ -124,7 +126,7 @@ impl Iterator<(Path, Path)> for Prefixes { impl ToStr for CrateId { fn to_str(&self) -> ~str { // should probably use the filestem and not the whole path - format!("{}-{}", self.path.as_str().unwrap(), self.version.to_str()) + format!("{}-{}", self.path.as_str().unwrap(), self.get_version()) } } |
