-Subproject commit da5c02546229eee6fb4305255333515bf8954fdd
+Subproject commit c305bcb84ed51d7bd808bc20c09c00a1beb1b087
-Subproject commit a0f63ba56099404b4ac1db513ad4d4ffd2d1a7c3
+Subproject commit 0de103ed19997884f2766456f7a003b94f1daa42
#[deriving(Eq,Clone,Decodable,Encodable)]
pub struct Options {
- manifest_path: Option<~str>
+ manifest_path: Option<StrBuf>
}
impl FlagConfig for Options {}
#[deriving(Eq,Clone,Decodable)]
struct Options {
- manifest_path: ~str
+ manifest_path: StrBuf
}
impl FlagConfig for Options {}
*/
fn main() {
- let arguments = args();
+ let arguments: Vec<StrBuf> = args().iter().map(|a| a.to_strbuf()).collect();
let opts = ~[
reqopt("m", "manifest", "the location of the manifest", "MANIFEST")
#[deriving(Encodable)]
struct ConfigOut {
- values: collections::HashMap<~str, config::ConfigValue>
+ values: collections::HashMap<StrBuf, config::ConfigValue>
}
#[deriving(Decodable)]
struct ConfigForKeyFlags {
- key: ~str,
+ key: StrBuf,
human: bool
}
use semver::Version;
-use core::{NameVer,VersionReq};
+use core::{VersionReq};
use util::CargoResult;
#[deriving(Eq,Clone,Show)]
impl Show for CargoError {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
match self {
- &CargoInternalError(ref err) => write!(f.buf, "{}", err),
- &CargoCLIError(ref err) => write!(f.buf, "{}", err)
+ &CargoInternalError(ref err) => write!(f, "{}", err),
+ &CargoCLIError(ref err) => write!(f, "{}", err)
}
}
}
impl Show for CLIError {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
- write!(f.buf, "{}", self.msg)
+ write!(f, "{}", self.msg)
}
}
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
match self {
&StringConversionError(ref string, ref type_name) => {
- write!(f.buf, "Couldn't convert `{}` into {}", string, type_name)
+ write!(f, "Couldn't convert `{}` into {}", string, type_name)
},
&MissingManifest(ref path, ref file) => {
- write!(f.buf, "Couldn't find a {} in the project (`{}` or any parent directory", file, path.display())
+ write!(f, "Couldn't find a {} in the project (`{}` or any parent directory", file, path.display())
},
&WrappedIoError(ref io_error) => {
- write!(f.buf, "{}", io_error)
+ write!(f, "{}", io_error)
},
&PathError(ref s) | &Described(ref s) => {
- write!(f.buf, "{}", s)
+ write!(f, "{}", s)
},
- &Other => write!(f.buf, "Other internal error")
+ &Other => write!(f, "Other internal error")
}
}
}
#[deriving(Eq,Clone)]
pub struct Manifest {
summary: Summary,
- authors: Vec<~str>,
+ authors: Vec<StrBuf>,
targets: Vec<Target>,
target_dir: Path,
}
impl Show for Manifest {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
- write!(f.buf, "Manifest({}, authors={}, targets={}, target_dir={})", self.summary, self.authors, self.targets, self.target_dir.display())
+ write!(f, "Manifest({}, authors={}, targets={}, target_dir={})", self.summary, self.authors, self.targets, self.target_dir.display())
}
}
#[deriving(Eq,Clone,Encodable)]
pub struct SerializedManifest {
- name: ~str,
- version: ~str,
+ name: StrBuf,
+ version: StrBuf,
dependencies: Vec<SerializedDependency>,
- authors: Vec<~str>,
+ authors: Vec<StrBuf>,
targets: Vec<Target>,
- target_dir: ~str
+ target_dir: StrBuf
}
impl<E, S: Encoder<E>> Encodable<S, E> for Manifest {
fn encode(&self, s: &mut S) -> Result<(), E> {
SerializedManifest {
- name: self.summary.get_name().to_owned(),
- version: self.summary.get_version().to_str(),
+ name: self.summary.get_name().to_strbuf(),
+ version: format_strbuf!("{}", self.summary.get_version()),
dependencies: self.summary.get_dependencies().iter().map(|d| SerializedDependency::from_dependency(d)).collect(),
authors: self.authors.clone(),
targets: self.targets.clone(),
- target_dir: self.target_dir.as_str().unwrap().to_owned()
+ target_dir: self.target_dir.as_str().unwrap().to_strbuf()
}.encode(s)
}
}
#[deriving(Clone,Eq)]
pub struct Target {
kind: TargetKind,
- name: ~str,
+ name: StrBuf,
path: Path
}
#[deriving(Encodable)]
pub struct SerializedTarget {
kind: &'static str,
- name: ~str,
- path: ~str
+ name: StrBuf,
+ path: StrBuf
}
impl<E, S: Encoder<E>> Encodable<S, E> for Target {
SerializedTarget {
kind: kind,
name: self.name.clone(),
- path: self.path.as_str().unwrap().to_owned()
+ path: self.path.as_str().unwrap().to_strbuf()
}.encode(s)
}
}
impl Show for Target {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
- write!(f.buf, "{}(name={}, path={})", self.kind, self.name, self.path.display())
+ write!(f, "{}(name={}, path={})", self.kind, self.name, self.path.display())
}
}
self.get_summary().get_name_ver().get_version()
}
- pub fn get_authors<'a>(&'a self) -> &'a [~str] {
+ pub fn get_authors<'a>(&'a self) -> &'a [StrBuf] {
self.authors.as_slice()
}
pub fn lib_target(name: &str, path: &Path) -> Target {
Target {
kind: LibTarget,
- name: name.to_owned(),
+ name: name.to_strbuf(),
path: path.clone()
}
}
pub fn bin_target(name: &str, path: &Path) -> Target {
Target {
kind: BinTarget,
- name: name.to_owned(),
+ name: name.to_strbuf(),
path: path.clone()
}
}
#[deriving(Decodable,Encodable,Eq,Clone,Show)]
pub struct Project {
- pub name: ~str,
- pub version: ~str,
- pub authors: ~[~str]
+ pub name: StrBuf,
+ pub version: StrBuf,
+ pub authors: Vec<StrBuf>
}
/*
project: Box<Project>,
lib: Option<~[TomlLibTarget]>,
bin: Option<~[TomlExecTarget]>,
- dependencies: Option<HashMap<~str, ~str>>
+ dependencies: Option<HashMap<StrBuf, StrBuf>>
}
impl TomlManifest {
match self.dependencies {
Some(ref dependencies) => {
for (n, v) in dependencies.iter() {
- deps.push(try!(Dependency::parse(*n, *v)));
+ deps.push(try!(Dependency::parse(n.as_slice(), v.as_slice())));
}
}
None => ()
impl Project {
fn to_name_ver(&self) -> NameVer {
- NameVer::new(self.name, self.version)
+ NameVer::new(self.name.as_slice(), self.version.as_slice())
}
}
#[deriving(Decodable,Encodable,Eq,Clone)]
struct TomlTarget {
- name: ~str,
- path: Option<~str>
+ name: StrBuf,
+ path: Option<StrBuf>
}
fn normalize(lib: &Option<~[TomlLibTarget]>, bin: &Option<~[TomlExecTarget]>) -> Vec<Target> {
fn lib_targets(dst: &mut Vec<Target>, libs: &[TomlLibTarget]) {
let l = &libs[0];
- let path = l.path.clone().unwrap_or_else(|| format!("src/{}.rs", l.name));
- dst.push(Target::lib_target(l.name, &Path::new(path)));
+ let path = l.path.clone().unwrap_or_else(|| format_strbuf!("src/{}.rs", l.name));
+ dst.push(Target::lib_target(l.name.as_slice(), &Path::new(path)));
}
- fn bin_targets(dst: &mut Vec<Target>, bins: &[TomlExecTarget], default: |&TomlExecTarget| -> ~str) {
+ fn bin_targets(dst: &mut Vec<Target>, bins: &[TomlExecTarget], default: |&TomlExecTarget| -> StrBuf) {
for bin in bins.iter() {
let path = bin.path.clone().unwrap_or_else(|| default(bin));
- dst.push(Target::bin_target(bin.name.clone(), &Path::new(path)));
+ dst.push(Target::bin_target(bin.name.as_slice(), &Path::new(path)));
}
}
match (lib, bin) {
(&Some(ref libs), &Some(ref bins)) => {
lib_targets(&mut ret, libs.as_slice());
- bin_targets(&mut ret, bins.as_slice(), |bin| format!("src/bin/{}.rs", bin.name));
+ bin_targets(&mut ret, bins.as_slice(), |bin| format_strbuf!("src/bin/{}.rs", bin.name));
},
(&Some(ref libs), &None) => {
lib_targets(&mut ret, libs.as_slice());
},
(&None, &Some(ref bins)) => {
- bin_targets(&mut ret, bins.as_slice(), |bin| format!("src/{}.rs", bin.name));
+ bin_targets(&mut ret, bins.as_slice(), |bin| format_strbuf!("src/{}.rs", bin.name));
},
(&None, &None) => ()
}
#[deriving(Clone,Eq,Ord)]
pub struct NameVer {
- name: ~str,
+ name: StrBuf,
version: semver::Version
}
impl NameVer {
pub fn new(name: &str, version: &str) -> NameVer {
- NameVer { name: name.to_owned(), version: semver::parse(version.to_owned()).unwrap() }
+ NameVer { name: name.to_strbuf(), version: semver::parse(version.to_owned()).unwrap() }
}
pub fn get_name<'a>(&'a self) -> &'a str {
impl Show for NameVer {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
- write!(f.buf, "{} v{}", self.name, self.version)
+ write!(f, "{} v{}", self.name, self.version)
}
}
impl<E, D: Decoder<E>> Decodable<D,E> for NameVer {
fn decode(d: &mut D) -> Result<NameVer, E> {
- let vector: Vec<~str> = try!(Decodable::decode(d));
- Ok(NameVer { name: vector.get(0).clone(), version: semver::parse(vector.get(1).clone()).unwrap() })
+ let vector: Vec<StrBuf> = try!(Decodable::decode(d));
+ Ok(NameVer { name: vector.get(0).clone(), version: semver::parse(vector.get(1).as_slice()).unwrap() })
}
}
impl<E, S: Encoder<E>> Encodable<S,E> for NameVer {
fn encode(&self, e: &mut S) -> Result<(), E> {
- (vec!(self.name.clone(), self.version.to_str())).encode(e)
+ (vec!(self.name.clone(), format_strbuf!("{}", self.version))).encode(e)
}
}
name: ~str,
version: ~str,
dependencies: Vec<SerializedDependency>,
- authors: Vec<~str>,
+ authors: Vec<StrBuf>,
targets: Vec<Target>,
root: ~str
}
impl Show for Package {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
- write!(f.buf, "{}", self.get_summary().get_name_ver())
+ write!(f, "{}", self.get_summary().get_name_ver())
}
}
impl fmt::Show for VersionReq {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
if self.predicates.is_empty() {
- try!(write!(fmt.buf, "*"));
+ try!(write!(fmt, "*"));
}
else {
for (i, ref pred) in self.predicates.iter().enumerate() {
if i == 0 {
- try!(write!(fmt.buf, "{}", pred));
+ try!(write!(fmt, "{}", pred));
}
else {
- try!(write!(fmt.buf, ", {}", pred));
+ try!(write!(fmt, ", {}", pred));
}
}
}
impl fmt::Show for Predicate {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
- try!(write!(fmt.buf, "{} {}", self.op, self.major));
+ try!(write!(fmt, "{} {}", self.op, self.major));
match self.minor {
- Some(v) => try!(write!(fmt.buf, ".{}", v)),
+ Some(v) => try!(write!(fmt, ".{}", v)),
None => ()
}
match self.patch {
- Some(v) => try!(write!(fmt.buf, ".{}", v)),
+ Some(v) => try!(write!(fmt, ".{}", v)),
None => ()
}
impl fmt::Show for Op {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
match *self {
- Ex => try!(write!(fmt.buf, "=")),
- Gt => try!(write!(fmt.buf, ">")),
- GtEq => try!(write!(fmt.buf, ">=")),
- Lt => try!(write!(fmt.buf, "<")),
- LtEq => try!(write!(fmt.buf, "<="))
+ Ex => try!(write!(fmt, "=")),
+ Gt => try!(write!(fmt, ">")),
+ GtEq => try!(write!(fmt, ">=")),
+ Lt => try!(write!(fmt, "<")),
+ LtEq => try!(write!(fmt, "<="))
}
Ok(())
}
Err(e) => handle_error(e),
Ok(encodable) => {
encodable.map(|encodable| {
- let encoded: ~str = json::Encoder::str_encode(&encodable);
+ let encoded = json::Encoder::str_encode(&encodable);
println!("{}", encoded);
});
}
std::os::set_exit_status(exit_code as int);
}
+fn args() -> Vec<StrBuf> {
+ std::os::args().iter().map(|a| a.to_strbuf()).collect()
+}
+
fn flags_from_args<T: RepresentsFlags>() -> CLIResult<T> {
- let mut decoder = FlagDecoder::new::<T>(std::os::args().tail());
+ let mut decoder = FlagDecoder::new::<T>(args().tail());
Decodable::decode(&mut decoder).to_result(|e: HammerError| CLIError::new(e.message, None, 1))
}
let configs = try!(config::all_configs(os::getcwd()));
- let config_paths = configs.find(&("paths".to_owned())).map(|v| v.clone()).unwrap_or_else(|| ConfigValue::new());
+ let config_paths = configs.find(&"paths".to_strbuf()).map(|v| v.clone()).unwrap_or_else(|| ConfigValue::new());
let mut paths: Vec<Path> = match config_paths.get_value() {
&config::String(_) => return Err(other_error("The path was configured as a String instead of a List")),
use util::{other_error,human_error,CargoResult,CargoError,ProcessBuilder};
use util::result::ProcessError;
-type Args = Vec<~str>;
+type Args = Vec<StrBuf>;
pub fn compile(pkgs: &core::PackageSet) -> CargoResult<()> {
let mut sorted = match pkgs.sort() {
let rustc = prepare_rustc(root, target, dest, deps);
try!(exec(&rustc)
- .map_err(|err| rustc_to_cargo_err(rustc.get_args(), root, err)));
+ .map_err(|err| rustc_to_cargo_err(rustc.get_args().as_slice(), root, err)));
Ok(())
}
}
fn build_base_args(into: &mut Args, target: &core::Target, dest: &Path) {
- into.push(target.get_path().as_str().unwrap().to_owned());
- into.push("--crate-type".to_owned());
- into.push(target.rustc_crate_type().to_owned());
- into.push("--out-dir".to_owned());
- into.push(dest.as_str().unwrap().to_owned());
+ into.push(target.get_path().as_str().unwrap().to_strbuf());
+ into.push("--crate-type".to_strbuf());
+ into.push(target.rustc_crate_type().to_strbuf());
+ into.push("--out-dir".to_strbuf());
+ into.push(dest.as_str().unwrap().to_strbuf());
}
fn build_deps_args(dst: &mut Args, deps: &[core::Package]) {
for dep in deps.iter() {
let dir = dep.get_absolute_target_dir();
- dst.push("-L".to_owned());
- dst.push(dir.as_str().unwrap().to_owned());
+ dst.push("-L".to_strbuf());
+ dst.push(dir.as_str().unwrap().to_strbuf());
}
}
-fn rustc_to_cargo_err(args: &[~str], cwd: &Path, err: CargoError) -> CargoError {
+fn rustc_to_cargo_err(args: &[StrBuf], cwd: &Path, err: CargoError) -> CargoError {
let msg = {
let output = match err {
CargoError { kind: ProcessError(_, ref output), .. } => output,
impl Show for PathSource {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
- write!(f.buf, "the paths source")
+ write!(f, "the paths source")
}
}
#[deriving(Eq,TotalEq,Clone,Decodable)]
pub enum ConfigValueValue {
- String(~str),
- List(Vec<~str>)
+ String(StrBuf),
+ List(Vec<StrBuf>)
}
impl fmt::Show for ConfigValueValue {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
- &String(ref string) => write!(f.buf, "{}", string),
- &List(ref list) => write!(f.buf, "{}", list)
+ &String(ref string) => write!(f, "{}", string),
+ &List(ref list) => write!(f, "{}", list)
}
}
}
impl fmt::Show for ConfigValue {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- let paths: Vec<~str> = self.path.iter().map(|p| p.display().to_str()).collect();
- write!(f.buf, "{} (from {})", self.value, paths)
+ let paths: Vec<StrBuf> = self.path.iter().map(|p| format_strbuf!("{}", p.display())).collect();
+ write!(f, "{} (from {})", self.value, paths)
}
}
.map_err(|_| other_error("config key not found").with_detail(format!("key={}", key)))
}
-pub fn all_configs(pwd: Path) -> CargoResult<HashMap<~str, ConfigValue>> {
+pub fn all_configs(pwd: Path) -> CargoResult<HashMap<StrBuf, ConfigValue>> {
let mut map = HashMap::new();
try!(walk_tree(&pwd, |file| {
}
#[allow(unused_variable)]
-pub fn set_config(key: ~str, value: ~str, location: Location) -> CargoResult<()> {
+pub fn set_config(key: StrBuf, value: StrBuf, location: Location) -> CargoResult<()> {
Ok(())
}
let val = try!(root.lookup(key).require(other_error("")));
let v = match val {
- &toml::String(ref val) => String(val.to_owned()),
- &toml::Array(ref val) => List(val.iter().map(|s: &toml::Value| s.to_str()).collect()),
+ &toml::String(ref val) => String(val.clone()),
+ &toml::Array(ref val) => List(val.iter().map(|s: &toml::Value| format_strbuf!("{}", s)).collect()),
_ => return Err(other_error(""))
};
Ok(ConfigValue{ value: v, path: vec!(path) })
}
-fn extract_all_configs(file: io::fs::File, map: &mut HashMap<~str, ConfigValue>) -> CargoResult<()> {
+fn extract_all_configs(file: io::fs::File, map: &mut HashMap<StrBuf, ConfigValue>) -> CargoResult<()> {
let path = file.path().clone();
let mut buf = io::BufferedReader::new(file);
let root = try!(toml::parse_from_buffer(&mut buf).map_err(|err|
for (key, value) in table.iter() {
match value {
- &toml::String(ref val) => { map.insert(key.to_owned(), ConfigValue { value: String(val.to_owned()), path: vec!(path.clone()) }); }
+ &toml::String(ref val) => { map.insert(key.clone(), ConfigValue { value: String(val.clone()), path: vec!(path.clone()) }); }
&toml::Array(ref val) => {
- let config = map.find_or_insert_with(key.to_owned(), |_| {
+ let config = map.find_or_insert_with(key.clone(), |_| {
ConfigValue { path: vec!(), value: List(vec!()) }
});
match existing.value {
String(_) => return Err(other_error("should be an Array, but it was a String")),
List(ref mut list) => {
- let new_list: Vec<CargoResult<~str>> = val.iter().map(|s: &toml::Value| toml_string(s)).collect();
+ let new_list: Vec<CargoResult<StrBuf>> = val.iter().map(|s: &toml::Value| toml_string(s)).collect();
if new_list.iter().any(|v| v.is_err()) {
return Err(other_error("should be an Array of Strings, but was an Array of other values"));
} else {
- let new_list: Vec<~str> = new_list.move_iter().map(|v| v.unwrap()).collect();
+ let new_list: Vec<StrBuf> = new_list.move_iter().map(|v| v.unwrap()).collect();
list.push_all(new_list.as_slice());
existing.path.push(path.clone());
Ok(())
}
}
-fn toml_string(val: &toml::Value) -> CargoResult<~str> {
+fn toml_string(val: &toml::Value) -> CargoResult<StrBuf> {
match val {
- &toml::String(ref str) => Ok(str.to_owned()),
+ &toml::String(ref str) => Ok(str.clone()),
_ => Err(other_error(""))
}
}
use std::fmt::{Show,Formatter};
use std::os;
use std::path::Path;
-use std::io::process::{Process,ProcessConfig,ProcessOutput,InheritFd};
+use std::io::process::{Command,ProcessOutput,InheritFd};
use util::{CargoResult,io_error,process_error};
use collections::HashMap;
#[deriving(Clone,Eq)]
pub struct ProcessBuilder {
- program: ~str,
- args: Vec<~str>,
- path: Vec<~str>,
- env: HashMap<~str, ~str>,
+ program: StrBuf,
+ args: Vec<StrBuf>,
+ path: Vec<StrBuf>,
+ env: HashMap<StrBuf, StrBuf>,
cwd: Path
}
impl Show for ProcessBuilder {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
- try!(write!(f.buf, "`{}", self.program));
+ try!(write!(f, "`{}", self.program));
if self.args.len() > 0 {
- try!(write!(f.buf, " {}", self.args.connect(" ")));
+ try!(write!(f, " {}", self.args.connect(" ")));
}
- write!(f.buf, "`")
+ write!(f, "`")
}
}
static PATH_SEP : &'static str = ":";
impl ProcessBuilder {
- pub fn args(mut self, arguments: &[~str]) -> ProcessBuilder {
+ pub fn args(mut self, arguments: &[StrBuf]) -> ProcessBuilder {
self.args = Vec::from_slice(arguments);
self
}
- pub fn get_args<'a>(&'a self) -> &'a [~str] {
+ pub fn get_args<'a>(&'a self) -> &'a [StrBuf] {
self.args.as_slice()
}
pub fn extra_path(mut self, path: Path) -> ProcessBuilder {
// For now, just convert to a string, but we should do something better
- self.path.push(format!("{}", path.display()));
+ self.path.push(format_strbuf!("{}", path.display()));
self
}
// TODO: should InheritFd be hardcoded?
pub fn exec(&self) -> CargoResult<()> {
- let mut config = try!(self.build_config());
- let env = self.build_env();
+ let mut command = self.build_command();
+ command
+ .env(self.build_env())
+ .stdout(InheritFd(1))
+ .stderr(InheritFd(2));
- // Set where the output goes
- config.env = Some(env.as_slice());
- config.stdout = InheritFd(1);
- config.stderr = InheritFd(2);
-
- let mut process = try!(Process::configure(config).map_err(io_error));
- let exit = process.wait();
+ let exit = try!(command.status().map_err(io_error));
if exit.success() {
Ok(())
}
pub fn exec_with_output(&self) -> CargoResult<ProcessOutput> {
- let mut config = try!(self.build_config());
- let env = self.build_env();
-
- config.env = Some(env.as_slice());
+ let mut command = self.build_command();
+ command.env(self.build_env());
- let output = try!(Process::configure(config).map(|mut ok| ok.wait_with_output()).map_err(io_error));
+ let output = try!(command.output().map_err(io_error));
if output.status.success() {
Ok(output)
}
}
- fn build_config<'a>(&'a self) -> CargoResult<ProcessConfig<'a>> {
- let mut config = ProcessConfig::new();
-
- config.program = self.program.as_slice();
- config.args = self.args.as_slice();
- config.cwd = Some(&self.cwd);
-
- Ok(config)
+ fn build_command(&self) -> Command {
+ let mut command = Command::new(self.program.as_slice());
+ command.args(self.args.as_slice()).cwd(&self.cwd);
+ command
}
- fn debug_string(&self) -> ~str {
- format!("{} {}", self.program, self.args.connect(" "))
+ fn debug_string(&self) -> StrBuf {
+ format_strbuf!("{} {}", self.program, self.args.connect(" "))
}
- fn build_env(&self) -> ~[(~str, ~str)] {
+ fn build_env(&self) -> ~[(StrBuf, StrBuf)] {
let mut ret = Vec::new();
for (key, val) in self.env.iter() {
}
match self.build_path() {
- Some(path) => ret.push(("PATH".to_owned(), path)),
+ Some(path) => ret.push(("PATH".to_strbuf(), path)),
_ => ()
}
ret.as_slice().to_owned()
}
- fn build_path(&self) -> Option<~str> {
+ fn build_path(&self) -> Option<StrBuf> {
let path = self.path.connect(PATH_SEP);
match self.env.find_equiv(&("PATH")) {
Some(existing) => {
if self.path.is_empty() {
- Some(existing.to_owned())
+ Some(existing.clone())
+ } else {
+ Some(format_strbuf!("{}{}{}", existing, PATH_SEP, path))
}
- else {
- Some(existing.as_slice() + PATH_SEP + path)
- }
- }
+ },
None => {
if self.path.is_empty() {
None
- }
- else {
- Some(path)
+ } else {
+ Some(path.to_strbuf())
}
}
}
pub fn process(cmd: &str) -> ProcessBuilder {
ProcessBuilder {
- program: cmd.to_owned(),
+ program: cmd.to_strbuf(),
args: vec!(),
path: vec!(),
cwd: os::getcwd(),
}
}
-fn system_env() -> HashMap<~str, ~str> {
+fn system_env() -> HashMap<StrBuf, StrBuf> {
let mut ret = HashMap::new();
for &(ref key, ref val) in os::env().iter() {
- ret.insert(key.clone(), val.clone());
+ ret.insert(key.to_strbuf(), val.to_strbuf());
}
ret
impl Show for CargoErrorKind {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
match self {
- &ProcessError(ref exit, _) => write!(f.buf, "ProcessError({})", exit),
- &HumanReadableError => write!(f.buf, "HumanReadableError"),
- &InternalError => write!(f.buf, "InternalError"),
- &IoError(ref err) => write!(f.buf, "IoError({})", err),
- &TomlError(ref err) => write!(f.buf, "TomlError({})", err),
- &OtherCargoError => write!(f.buf, "OtherCargoError")
+ &ProcessError(ref exit, _) => write!(f, "ProcessError({})", exit),
+ &HumanReadableError => write!(f, "HumanReadableError"),
+ &InternalError => write!(f, "InternalError"),
+ &IoError(ref err) => write!(f, "IoError({})", err),
+ &TomlError(ref err) => write!(f, "TomlError({})", err),
+ &OtherCargoError => write!(f, "OtherCargoError")
}
}
}