Skip to content

Commit

Permalink
Auto merge of #5509 - Eh2406:use_the_new, r=alexcrichton
Browse files Browse the repository at this point in the history
Use the new stable

The new rust release has stabilized `Box::leak` and `impl Iterator` lets use them!
  • Loading branch information
bors committed May 10, 2018
2 parents 7067bc8 + 19cb91f commit c807445
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
11 changes: 1 addition & 10 deletions src/cargo/core/interning.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,14 @@ use serde::{Serialize, Serializer};
use std::fmt;
use std::sync::RwLock;
use std::collections::HashSet;
use std::slice;
use std::str;
use std::mem;
use std::ptr;
use std::cmp::Ordering;
use std::ops::Deref;
use std::hash::{Hash, Hasher};

pub fn leak(s: String) -> &'static str {
let boxed = s.into_boxed_str();
let ptr = boxed.as_ptr();
let len = boxed.len();
mem::forget(boxed);
unsafe {
let slice = slice::from_raw_parts(ptr, len);
str::from_utf8_unchecked(slice)
}
Box::leak(s.into_boxed_str())
}

lazy_static! {
Expand Down
11 changes: 4 additions & 7 deletions src/cargo/core/resolver/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,10 @@ impl DepsFrame {
.unwrap_or(0)
}

pub fn flatten<'s>(&'s self) -> Box<Iterator<Item = (&PackageId, Dependency)> + 's> {
// TODO: with impl Trait the Box can be removed
Box::new(
self.remaining_siblings
.clone()
.map(move |(_, (d, _, _))| (self.parent.package_id(), d)),
)
pub fn flatten<'s>(&'s self) -> impl Iterator<Item=(&PackageId, Dependency)> + 's {
self.remaining_siblings
.clone()
.map(move |(_, (d, _, _))| (self.parent.package_id(), d))
}
}

Expand Down

0 comments on commit c807445

Please sign in to comment.