}
pub fn new_override(name: &str, source_id: &SourceId) -> Dependency {
- assert!(name.len() > 0);
+ assert!(!name.is_empty());
Dependency {
inner: Rc::new(Inner {
name: InternedString::new(name),
InternedString { inner: s }
}
-
- pub fn as_str(&self) -> &'static str {
- self.inner
+ pub fn to_inner(&self) -> &'static str {
+ unsafe {
+ let slice = slice::from_raw_parts(self.ptr, self.len);
+ str::from_utf8_unchecked(slice)
+ }
}
}
}
impl<'r> Requirements<'r> {
- fn new<'a>(summary: &'a Summary) -> Requirements<'a> {
+ fn new(summary: &Summary) -> Requirements {
Requirements {
summary,
deps: HashMap::new(),
.remaining_siblings
.clone()
.filter_map(|(_, (ref new_dep, _, _))| {
- past_conflicting_activations.conflicting(&cx, &new_dep)
+ past_conflicting_activations.conflicting(&cx, new_dep)
})
.next()
{
///
/// Read <https://github.com/rust-lang/cargo/pull/4834>
/// For several more detailed explanations of the logic here.
-fn find_candidate<'a>(
+fn find_candidate(
backtrack_stack: &mut Vec<BacktrackFrame>,
parent: &Summary,
conflicting_activations: &HashMap<PackageId, ConflictReason>,
let previous_cmp = a_in_previous.cmp(&b_in_previous).reverse();
match previous_cmp {
Ordering::Equal => {
- let cmp = a.summary.version().cmp(&b.summary.version());
- if self.minimal_versions == true {
+ let cmp = a.summary.version().cmp(b.summary.version());
+ if self.minimal_versions {
// Lower version ordered first.
cmp
} else {
let mkopts = MkOptions {
version_control: opts.version_control,
- path: &path,
+ path,
name,
source_files: vec![plan_new_source_file(opts.kind.is_bin(), name.to_string())],
bin: opts.kind.is_bin(),
bail!("`cargo init` cannot be run on existing Cargo projects")
}
- let name = get_name(&path, opts)?;
+ let name = get_name(path, opts)?;
check_name(name, opts)?;
let mut src_paths_types = vec![];
- detect_source_paths_and_types(&path, name, &mut src_paths_types)?;
+ detect_source_paths_and_types(path, name, &mut src_paths_types)?;
if src_paths_types.is_empty() {
src_paths_types.push(plan_new_source_file(opts.kind.is_bin(), name.to_string()));
match vcs {
VersionControl::Git => {
- if !fs::metadata(&path.join(".git")).is_ok() {
+ if fs::metadata(&path.join(".git")).is_err() {
GitRepo::init(path, config.cwd())?;
}
let ignore = match fs::metadata(&path.join(".gitignore")) {
paths::append(&path.join(".gitignore"), ignore.as_bytes())?;
}
VersionControl::Hg => {
- if !fs::metadata(&path.join(".hg")).is_ok() {
+ if fs::metadata(&path.join(".hg")).is_err() {
HgRepo::init(path, config.cwd())?;
}
let hgignore = match fs::metadata(&path.join(".hgignore")) {
paths::append(&path.join(".hgignore"), hgignore.as_bytes())?;
}
VersionControl::Pijul => {
- if !fs::metadata(&path.join(".pijul")).is_ok() {
+ if fs::metadata(&path.join(".pijul")).is_err() {
PijulRepo::init(path, config.cwd())?;
}
let ignore = match fs::metadata(&path.join(".ignore")) {
paths::append(&path.join(".ignore"), ignore.as_bytes())?;
}
VersionControl::Fossil => {
- if !fs::metadata(&path.join(".fossil")).is_ok() {
+ if fs::metadata(&path.join(".fossil")).is_err() {
FossilRepo::init(path, config.cwd())?;
}
}
.iter()
.map(|file| util::without_prefix(file, root).unwrap().to_path_buf())
.collect();
- if include_lockfile(&pkg) {
+ if include_lockfile(pkg) {
list.push("Cargo.lock".into());
}
list.sort();
Packages::Packages(ref xs) => match xs.len() {
0 => ws.current()?,
1 => ws.members()
- .find(|pkg| &*pkg.name() == xs[0])
+ .find(|pkg| *pkg.name() == xs[0])
.ok_or_else(|| {
format_err!("package `{}` is not a member of the workspace", xs[0])
})?,
&& (unit.target.is_dylib() || unit.target.is_cdylib()
|| (unit.target.is_bin() && cx.target_triple().starts_with("wasm32-")))
&& unit.pkg.package_id().source_id().is_path()
- && !__cargo_default_lib_metadata.is_ok()
+ && __cargo_default_lib_metadata.is_err()
{
return None;
}
}
let search_max_limit = 100;
- if total_crates > u32::from(limit) && limit < search_max_limit {
+ if total_crates > limit && limit < search_max_limit {
println!(
"... and {} crates more (use --limit N to see more)",
- total_crates - u32::from(limit)
+ total_crates - limit
);
- } else if total_crates > u32::from(limit) && limit >= search_max_limit {
+ } else if total_crates > limit && limit >= search_max_limit {
println!(
"... and {} crates more (go to http://crates.io/search?q={} to see more)",
- total_crates - u32::from(limit),
+ total_crates - limit,
percent_encode(query.as_bytes(), QUERY_ENCODE_SET)
);
}
})()
.chain_err(|| format!("failed to find tag `{}`", s))?,
GitReference::Branch(ref s) => {
- (|| {
- let b = repo.find_branch(s, git2::BranchType::Local)?;
- b.get()
- .target()
- .ok_or_else(|| format_err!("branch `{}` did not have a target", s))
- })()
- .chain_err(|| format!("failed to find branch `{}`", s))?
+ let b = repo.find_branch(s, git2::BranchType::Local)
+ .chain_err(|| format!("failed to find branch `{}`", s))?;
+ b.get()
+ .target()
+ .ok_or_else(|| format_err!("branch `{}` did not have a target", s))?
}
GitReference::Rev(ref s) => {
let obj = repo.revparse_single(s)?;
Err(e) => e,
};
- if err.kind() == io::ErrorKind::PermissionDenied {
- if set_not_readonly(p).unwrap_or(false) {
- match fs::remove_file(p) {
- Ok(()) => return Ok(()),
- Err(e) => err = e,
- }
+ if err.kind() == io::ErrorKind::PermissionDenied && set_not_readonly(p).unwrap_or(false) {
+ match fs::remove_file(p) {
+ Ok(()) => return Ok(()),
+ Err(e) => err = e,
}
}