mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 06:51:58 +00:00
alloc, arena, test, url, uuid: Elide lifetimes.
Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
This commit is contained in:
parent
2467c6e5a7
commit
f86184869a
@ -226,7 +226,7 @@ impl<T: Clone> Rc<T> {
|
||||
/// data is cloned if the reference count is greater than one.
|
||||
#[inline]
|
||||
#[experimental]
|
||||
pub fn make_unique<'a>(&'a mut self) -> &'a mut T {
|
||||
pub fn make_unique(&mut self) -> &mut T {
|
||||
// Note that we hold a strong reference, which also counts as
|
||||
// a weak reference, so we only clone if there is an
|
||||
// additional reference of either kind.
|
||||
@ -247,7 +247,7 @@ impl<T: Clone> Rc<T> {
|
||||
impl<T> Deref<T> for Rc<T> {
|
||||
/// Borrow the value contained in the reference-counted box
|
||||
#[inline(always)]
|
||||
fn deref<'a>(&'a self) -> &'a T {
|
||||
fn deref(&self) -> &T {
|
||||
&self.inner().value
|
||||
}
|
||||
}
|
||||
@ -390,7 +390,7 @@ impl<T> Clone for Weak<T> {
|
||||
|
||||
#[doc(hidden)]
|
||||
trait RcBoxPtr<T> {
|
||||
fn inner<'a>(&'a self) -> &'a RcBox<T>;
|
||||
fn inner(&self) -> &RcBox<T>;
|
||||
|
||||
#[inline]
|
||||
fn strong(&self) -> uint { self.inner().strong.get() }
|
||||
@ -413,12 +413,12 @@ trait RcBoxPtr<T> {
|
||||
|
||||
impl<T> RcBoxPtr<T> for Rc<T> {
|
||||
#[inline(always)]
|
||||
fn inner<'a>(&'a self) -> &'a RcBox<T> { unsafe { &(*self._ptr) } }
|
||||
fn inner(&self) -> &RcBox<T> { unsafe { &(*self._ptr) } }
|
||||
}
|
||||
|
||||
impl<T> RcBoxPtr<T> for Weak<T> {
|
||||
#[inline(always)]
|
||||
fn inner<'a>(&'a self) -> &'a RcBox<T> { unsafe { &(*self._ptr) } }
|
||||
fn inner(&self) -> &RcBox<T> { unsafe { &(*self._ptr) } }
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -207,7 +207,7 @@ impl Arena {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn alloc_copy<'a, T>(&'a self, op: || -> T) -> &'a T {
|
||||
fn alloc_copy<T>(&self, op: || -> T) -> &T {
|
||||
unsafe {
|
||||
let ptr = self.alloc_copy_inner(mem::size_of::<T>(),
|
||||
mem::min_align_of::<T>());
|
||||
@ -261,7 +261,7 @@ impl Arena {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn alloc_noncopy<'a, T>(&'a self, op: || -> T) -> &'a T {
|
||||
fn alloc_noncopy<T>(&self, op: || -> T) -> &T {
|
||||
unsafe {
|
||||
let tydesc = get_tydesc::<T>();
|
||||
let (ty_ptr, ptr) =
|
||||
@ -285,7 +285,7 @@ impl Arena {
|
||||
/// Allocate a new item in the arena, using `op` to initialize the value
|
||||
/// and returning a reference to it.
|
||||
#[inline]
|
||||
pub fn alloc<'a, T>(&'a self, op: || -> T) -> &'a T {
|
||||
pub fn alloc<T>(&self, op: || -> T) -> &T {
|
||||
unsafe {
|
||||
if intrinsics::needs_drop::<T>() {
|
||||
self.alloc_noncopy(op)
|
||||
@ -458,13 +458,13 @@ impl<T> TypedArena<T> {
|
||||
|
||||
/// Allocates an object in the TypedArena, returning a reference to it.
|
||||
#[inline]
|
||||
pub fn alloc<'a>(&'a self, object: T) -> &'a T {
|
||||
pub fn alloc(&self, object: T) -> &T {
|
||||
if self.ptr == self.end {
|
||||
self.grow()
|
||||
}
|
||||
|
||||
let ptr: &'a T = unsafe {
|
||||
let ptr: &'a mut T = mem::transmute(self.ptr);
|
||||
let ptr: &T = unsafe {
|
||||
let ptr: &mut T = mem::transmute(self.ptr);
|
||||
ptr::write(ptr, object);
|
||||
self.ptr.set(self.ptr.get().offset(1));
|
||||
ptr
|
||||
|
@ -164,7 +164,7 @@ impl<T: FloatMath + FromPrimitive> Summary<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a,T: FloatMath + FromPrimitive> Stats<T> for &'a [T] {
|
||||
impl<'a, T: FloatMath + FromPrimitive> Stats<T> for &'a [T] {
|
||||
|
||||
// FIXME #11059 handle NaN, inf and overflow
|
||||
fn sum(self) -> T {
|
||||
|
@ -394,7 +394,7 @@ pub fn decode_form_urlencoded(s: &[u8])
|
||||
}
|
||||
}
|
||||
|
||||
fn split_char_first<'a>(s: &'a str, c: char) -> (&'a str, &'a str) {
|
||||
fn split_char_first(s: &str, c: char) -> (&str, &str) {
|
||||
let mut iter = s.splitn(c, 1);
|
||||
|
||||
match (iter.next(), iter.next()) {
|
||||
@ -466,7 +466,7 @@ pub fn query_to_str(query: &Query) -> String {
|
||||
/// };
|
||||
/// println!("Scheme in use: {}.", scheme); // Scheme in use: https.
|
||||
/// ```
|
||||
pub fn get_scheme<'a>(rawurl: &'a str) -> DecodeResult<(&'a str, &'a str)> {
|
||||
pub fn get_scheme(rawurl: &str) -> DecodeResult<(&str, &str)> {
|
||||
for (i,c) in rawurl.chars().enumerate() {
|
||||
let result = match c {
|
||||
'A' .. 'Z'
|
||||
@ -493,8 +493,8 @@ pub fn get_scheme<'a>(rawurl: &'a str) -> DecodeResult<(&'a str, &'a str)> {
|
||||
}
|
||||
|
||||
// returns userinfo, host, port, and unparsed part, or an error
|
||||
fn get_authority<'a>(rawurl: &'a str) ->
|
||||
DecodeResult<(Option<UserInfo>, &'a str, Option<u16>, &'a str)> {
|
||||
fn get_authority(rawurl: &str) ->
|
||||
DecodeResult<(Option<UserInfo>, &str, Option<u16>, &str)> {
|
||||
enum State {
|
||||
Start, // starting state
|
||||
PassHostPort, // could be in user or port
|
||||
@ -662,8 +662,7 @@ fn get_authority<'a>(rawurl: &'a str) ->
|
||||
|
||||
|
||||
// returns the path and unparsed part of url, or an error
|
||||
fn get_path<'a>(rawurl: &'a str, is_authority: bool)
|
||||
-> DecodeResult<(String, &'a str)> {
|
||||
fn get_path(rawurl: &str, is_authority: bool) -> DecodeResult<(String, &str)> {
|
||||
let len = rawurl.len();
|
||||
let mut end = len;
|
||||
for (i,c) in rawurl.chars().enumerate() {
|
||||
|
@ -313,7 +313,7 @@ impl Uuid {
|
||||
}
|
||||
|
||||
/// Return an array of 16 octets containing the UUID data
|
||||
pub fn as_bytes<'a>(&'a self) -> &'a [u8] {
|
||||
pub fn as_bytes(&self) -> &[u8] {
|
||||
self.bytes.as_slice()
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user