mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 16:54:01 +00:00
Rollup merge of #59056 - scottmcm:even-fewer-lifetimes, r=sfackler
Use lifetime contravariance to elide more lifetimes in core+alloc+std Sample: ```diff - impl<'a, 'b, A: ?Sized, B: ?Sized> PartialEq<&'b mut B> for &'a mut A where A: PartialEq<B> { + impl<A: ?Sized, B: ?Sized> PartialEq<&mut B> for &mut A where A: PartialEq<B> { #[inline] - fn eq(&self, other: &&'b mut B) -> bool { PartialEq::eq(*self, *other) } + fn eq(&self, other: &&mut B) -> bool { PartialEq::eq(*self, *other) } #[inline] - fn ne(&self, other: &&'b mut B) -> bool { PartialEq::ne(*self, *other) } + fn ne(&self, other: &&mut B) -> bool { PartialEq::ne(*self, *other) } } ``` [I didn't know this worked](https://internals.rust-lang.org/t/why-can-you-use-different-unconstrained-lifetimes-to-implement-traits/9544/2?u=scottmcm) until recently, but since defining methods contravariantly in their lifetimes this way has worked back to Rust 1.0, we might as well take advantage of combining it with IHLE.
This commit is contained in:
commit
68abd9a999
@ -489,7 +489,7 @@ impl<T: ?Sized> From<Box<T>> for Pin<Box<T>> {
|
||||
}
|
||||
|
||||
#[stable(feature = "box_from_slice", since = "1.17.0")]
|
||||
impl<'a, T: Copy> From<&'a [T]> for Box<[T]> {
|
||||
impl<T: Copy> From<&[T]> for Box<[T]> {
|
||||
/// Converts a `&[T]` into a `Box<[T]>`
|
||||
///
|
||||
/// This conversion allocates on the heap
|
||||
@ -503,7 +503,7 @@ impl<'a, T: Copy> From<&'a [T]> for Box<[T]> {
|
||||
///
|
||||
/// println!("{:?}", boxed_slice);
|
||||
/// ```
|
||||
fn from(slice: &'a [T]) -> Box<[T]> {
|
||||
fn from(slice: &[T]) -> Box<[T]> {
|
||||
let mut boxed = unsafe { RawVec::with_capacity(slice.len()).into_box() };
|
||||
boxed.copy_from_slice(slice);
|
||||
boxed
|
||||
@ -511,7 +511,7 @@ impl<'a, T: Copy> From<&'a [T]> for Box<[T]> {
|
||||
}
|
||||
|
||||
#[stable(feature = "box_from_slice", since = "1.17.0")]
|
||||
impl<'a> From<&'a str> for Box<str> {
|
||||
impl From<&str> for Box<str> {
|
||||
/// Converts a `&str` into a `Box<str>`
|
||||
///
|
||||
/// This conversion allocates on the heap
|
||||
@ -523,7 +523,7 @@ impl<'a> From<&'a str> for Box<str> {
|
||||
/// println!("{}", boxed);
|
||||
/// ```
|
||||
#[inline]
|
||||
fn from(s: &'a str) -> Box<str> {
|
||||
fn from(s: &str) -> Box<str> {
|
||||
unsafe { from_boxed_utf8_unchecked(Box::from(s.as_bytes())) }
|
||||
}
|
||||
}
|
||||
|
@ -1145,7 +1145,7 @@ impl<T> From<T> for Rc<T> {
|
||||
}
|
||||
|
||||
#[stable(feature = "shared_from_slice", since = "1.21.0")]
|
||||
impl<'a, T: Clone> From<&'a [T]> for Rc<[T]> {
|
||||
impl<T: Clone> From<&[T]> for Rc<[T]> {
|
||||
#[inline]
|
||||
fn from(v: &[T]) -> Rc<[T]> {
|
||||
<Self as RcFromSlice<T>>::from_slice(v)
|
||||
@ -1153,7 +1153,7 @@ impl<'a, T: Clone> From<&'a [T]> for Rc<[T]> {
|
||||
}
|
||||
|
||||
#[stable(feature = "shared_from_slice", since = "1.21.0")]
|
||||
impl<'a> From<&'a str> for Rc<str> {
|
||||
impl From<&str> for Rc<str> {
|
||||
#[inline]
|
||||
fn from(v: &str) -> Rc<str> {
|
||||
let rc = Rc::<[u8]>::from(v.as_bytes());
|
||||
|
@ -2172,9 +2172,9 @@ impl AsRef<[u8]> for String {
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<'a> From<&'a str> for String {
|
||||
impl From<&str> for String {
|
||||
#[inline]
|
||||
fn from(s: &'a str) -> String {
|
||||
fn from(s: &str) -> String {
|
||||
s.to_owned()
|
||||
}
|
||||
}
|
||||
|
@ -2182,25 +2182,25 @@ impl<T> AsMut<[T]> for Vec<T> {
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<'a, T: Clone> From<&'a [T]> for Vec<T> {
|
||||
impl<T: Clone> From<&[T]> for Vec<T> {
|
||||
#[cfg(not(test))]
|
||||
fn from(s: &'a [T]) -> Vec<T> {
|
||||
fn from(s: &[T]) -> Vec<T> {
|
||||
s.to_vec()
|
||||
}
|
||||
#[cfg(test)]
|
||||
fn from(s: &'a [T]) -> Vec<T> {
|
||||
fn from(s: &[T]) -> Vec<T> {
|
||||
crate::slice::to_vec(s)
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "vec_from_mut", since = "1.19.0")]
|
||||
impl<'a, T: Clone> From<&'a mut [T]> for Vec<T> {
|
||||
impl<T: Clone> From<&mut [T]> for Vec<T> {
|
||||
#[cfg(not(test))]
|
||||
fn from(s: &'a mut [T]) -> Vec<T> {
|
||||
fn from(s: &mut [T]) -> Vec<T> {
|
||||
s.to_vec()
|
||||
}
|
||||
#[cfg(test)]
|
||||
fn from(s: &'a mut [T]) -> Vec<T> {
|
||||
fn from(s: &mut [T]) -> Vec<T> {
|
||||
crate::slice::to_vec(s)
|
||||
}
|
||||
}
|
||||
@ -2231,8 +2231,8 @@ impl<T> From<Vec<T>> for Box<[T]> {
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<'a> From<&'a str> for Vec<u8> {
|
||||
fn from(s: &'a str) -> Vec<u8> {
|
||||
impl From<&str> for Vec<u8> {
|
||||
fn from(s: &str) -> Vec<u8> {
|
||||
From::from(s.as_bytes())
|
||||
}
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ macro_rules! array_impls {
|
||||
}
|
||||
|
||||
#[stable(feature = "try_from", since = "1.34.0")]
|
||||
impl<'a, T> TryFrom<&'a [T]> for [T; $N] where T: Copy {
|
||||
impl<T> TryFrom<&[T]> for [T; $N] where T: Copy {
|
||||
type Error = TryFromSliceError;
|
||||
|
||||
fn try_from(slice: &[T]) -> Result<[T; $N], TryFromSliceError> {
|
||||
|
@ -1004,26 +1004,26 @@ mod impls {
|
||||
// & pointers
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<'a, 'b, A: ?Sized, B: ?Sized> PartialEq<&'b B> for &'a A where A: PartialEq<B> {
|
||||
impl<A: ?Sized, B: ?Sized> PartialEq<&B> for &A where A: PartialEq<B> {
|
||||
#[inline]
|
||||
fn eq(&self, other: & &'b B) -> bool { PartialEq::eq(*self, *other) }
|
||||
fn eq(&self, other: & &B) -> bool { PartialEq::eq(*self, *other) }
|
||||
#[inline]
|
||||
fn ne(&self, other: & &'b B) -> bool { PartialEq::ne(*self, *other) }
|
||||
fn ne(&self, other: & &B) -> bool { PartialEq::ne(*self, *other) }
|
||||
}
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<'a, 'b, A: ?Sized, B: ?Sized> PartialOrd<&'b B> for &'a A where A: PartialOrd<B> {
|
||||
impl<A: ?Sized, B: ?Sized> PartialOrd<&B> for &A where A: PartialOrd<B> {
|
||||
#[inline]
|
||||
fn partial_cmp(&self, other: &&'b B) -> Option<Ordering> {
|
||||
fn partial_cmp(&self, other: &&B) -> Option<Ordering> {
|
||||
PartialOrd::partial_cmp(*self, *other)
|
||||
}
|
||||
#[inline]
|
||||
fn lt(&self, other: & &'b B) -> bool { PartialOrd::lt(*self, *other) }
|
||||
fn lt(&self, other: & &B) -> bool { PartialOrd::lt(*self, *other) }
|
||||
#[inline]
|
||||
fn le(&self, other: & &'b B) -> bool { PartialOrd::le(*self, *other) }
|
||||
fn le(&self, other: & &B) -> bool { PartialOrd::le(*self, *other) }
|
||||
#[inline]
|
||||
fn ge(&self, other: & &'b B) -> bool { PartialOrd::ge(*self, *other) }
|
||||
fn ge(&self, other: & &B) -> bool { PartialOrd::ge(*self, *other) }
|
||||
#[inline]
|
||||
fn gt(&self, other: & &'b B) -> bool { PartialOrd::gt(*self, *other) }
|
||||
fn gt(&self, other: & &B) -> bool { PartialOrd::gt(*self, *other) }
|
||||
}
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<A: ?Sized> Ord for &A where A: Ord {
|
||||
@ -1036,26 +1036,26 @@ mod impls {
|
||||
// &mut pointers
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<'a, 'b, A: ?Sized, B: ?Sized> PartialEq<&'b mut B> for &'a mut A where A: PartialEq<B> {
|
||||
impl<A: ?Sized, B: ?Sized> PartialEq<&mut B> for &mut A where A: PartialEq<B> {
|
||||
#[inline]
|
||||
fn eq(&self, other: &&'b mut B) -> bool { PartialEq::eq(*self, *other) }
|
||||
fn eq(&self, other: &&mut B) -> bool { PartialEq::eq(*self, *other) }
|
||||
#[inline]
|
||||
fn ne(&self, other: &&'b mut B) -> bool { PartialEq::ne(*self, *other) }
|
||||
fn ne(&self, other: &&mut B) -> bool { PartialEq::ne(*self, *other) }
|
||||
}
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<'a, 'b, A: ?Sized, B: ?Sized> PartialOrd<&'b mut B> for &'a mut A where A: PartialOrd<B> {
|
||||
impl<A: ?Sized, B: ?Sized> PartialOrd<&mut B> for &mut A where A: PartialOrd<B> {
|
||||
#[inline]
|
||||
fn partial_cmp(&self, other: &&'b mut B) -> Option<Ordering> {
|
||||
fn partial_cmp(&self, other: &&mut B) -> Option<Ordering> {
|
||||
PartialOrd::partial_cmp(*self, *other)
|
||||
}
|
||||
#[inline]
|
||||
fn lt(&self, other: &&'b mut B) -> bool { PartialOrd::lt(*self, *other) }
|
||||
fn lt(&self, other: &&mut B) -> bool { PartialOrd::lt(*self, *other) }
|
||||
#[inline]
|
||||
fn le(&self, other: &&'b mut B) -> bool { PartialOrd::le(*self, *other) }
|
||||
fn le(&self, other: &&mut B) -> bool { PartialOrd::le(*self, *other) }
|
||||
#[inline]
|
||||
fn ge(&self, other: &&'b mut B) -> bool { PartialOrd::ge(*self, *other) }
|
||||
fn ge(&self, other: &&mut B) -> bool { PartialOrd::ge(*self, *other) }
|
||||
#[inline]
|
||||
fn gt(&self, other: &&'b mut B) -> bool { PartialOrd::gt(*self, *other) }
|
||||
fn gt(&self, other: &&mut B) -> bool { PartialOrd::gt(*self, *other) }
|
||||
}
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<A: ?Sized> Ord for &mut A where A: Ord {
|
||||
@ -1066,18 +1066,18 @@ mod impls {
|
||||
impl<A: ?Sized> Eq for &mut A where A: Eq {}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<'a, 'b, A: ?Sized, B: ?Sized> PartialEq<&'b mut B> for &'a A where A: PartialEq<B> {
|
||||
impl<A: ?Sized, B: ?Sized> PartialEq<&mut B> for &A where A: PartialEq<B> {
|
||||
#[inline]
|
||||
fn eq(&self, other: &&'b mut B) -> bool { PartialEq::eq(*self, *other) }
|
||||
fn eq(&self, other: &&mut B) -> bool { PartialEq::eq(*self, *other) }
|
||||
#[inline]
|
||||
fn ne(&self, other: &&'b mut B) -> bool { PartialEq::ne(*self, *other) }
|
||||
fn ne(&self, other: &&mut B) -> bool { PartialEq::ne(*self, *other) }
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<'a, 'b, A: ?Sized, B: ?Sized> PartialEq<&'b B> for &'a mut A where A: PartialEq<B> {
|
||||
impl<A: ?Sized, B: ?Sized> PartialEq<&B> for &mut A where A: PartialEq<B> {
|
||||
#[inline]
|
||||
fn eq(&self, other: &&'b B) -> bool { PartialEq::eq(*self, *other) }
|
||||
fn eq(&self, other: &&B) -> bool { PartialEq::eq(*self, *other) }
|
||||
#[inline]
|
||||
fn ne(&self, other: &&'b B) -> bool { PartialEq::ne(*self, *other) }
|
||||
fn ne(&self, other: &&B) -> bool { PartialEq::ne(*self, *other) }
|
||||
}
|
||||
}
|
||||
|
@ -37,21 +37,21 @@ macro_rules! forward_ref_binop {
|
||||
}
|
||||
|
||||
#[$attr]
|
||||
impl<'a> $imp<&'a $u> for $t {
|
||||
impl $imp<&$u> for $t {
|
||||
type Output = <$t as $imp<$u>>::Output;
|
||||
|
||||
#[inline]
|
||||
fn $method(self, other: &'a $u) -> <$t as $imp<$u>>::Output {
|
||||
fn $method(self, other: &$u) -> <$t as $imp<$u>>::Output {
|
||||
$imp::$method(self, *other)
|
||||
}
|
||||
}
|
||||
|
||||
#[$attr]
|
||||
impl<'a, 'b> $imp<&'a $u> for &'b $t {
|
||||
impl $imp<&$u> for &$t {
|
||||
type Output = <$t as $imp<$u>>::Output;
|
||||
|
||||
#[inline]
|
||||
fn $method(self, other: &'a $u) -> <$t as $imp<$u>>::Output {
|
||||
fn $method(self, other: &$u) -> <$t as $imp<$u>>::Output {
|
||||
$imp::$method(*self, *other)
|
||||
}
|
||||
}
|
||||
@ -67,9 +67,9 @@ macro_rules! forward_ref_op_assign {
|
||||
};
|
||||
(impl $imp:ident, $method:ident for $t:ty, $u:ty, #[$attr:meta]) => {
|
||||
#[$attr]
|
||||
impl<'a> $imp<&'a $u> for $t {
|
||||
impl $imp<&$u> for $t {
|
||||
#[inline]
|
||||
fn $method(&mut self, other: &'a $u) {
|
||||
fn $method(&mut self, other: &$u) {
|
||||
$imp::$method(self, *other);
|
||||
}
|
||||
}
|
||||
|
@ -2837,15 +2837,15 @@ impl<T: ?Sized> fmt::Pointer for Unique<T> {
|
||||
}
|
||||
|
||||
#[unstable(feature = "ptr_internals", issue = "0")]
|
||||
impl<'a, T: ?Sized> From<&'a mut T> for Unique<T> {
|
||||
fn from(reference: &'a mut T) -> Self {
|
||||
impl<T: ?Sized> From<&mut T> for Unique<T> {
|
||||
fn from(reference: &mut T) -> Self {
|
||||
unsafe { Unique { pointer: reference as *mut T, _marker: PhantomData } }
|
||||
}
|
||||
}
|
||||
|
||||
#[unstable(feature = "ptr_internals", issue = "0")]
|
||||
impl<'a, T: ?Sized> From<&'a T> for Unique<T> {
|
||||
fn from(reference: &'a T) -> Self {
|
||||
impl<T: ?Sized> From<&T> for Unique<T> {
|
||||
fn from(reference: &T) -> Self {
|
||||
unsafe { Unique { pointer: reference as *const T, _marker: PhantomData } }
|
||||
}
|
||||
}
|
||||
@ -3049,17 +3049,17 @@ impl<T: ?Sized> From<Unique<T>> for NonNull<T> {
|
||||
}
|
||||
|
||||
#[stable(feature = "nonnull", since = "1.25.0")]
|
||||
impl<'a, T: ?Sized> From<&'a mut T> for NonNull<T> {
|
||||
impl<T: ?Sized> From<&mut T> for NonNull<T> {
|
||||
#[inline]
|
||||
fn from(reference: &'a mut T) -> Self {
|
||||
fn from(reference: &mut T) -> Self {
|
||||
unsafe { NonNull { pointer: reference as *mut T } }
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "nonnull", since = "1.25.0")]
|
||||
impl<'a, T: ?Sized> From<&'a T> for NonNull<T> {
|
||||
impl<T: ?Sized> From<&T> for NonNull<T> {
|
||||
#[inline]
|
||||
fn from(reference: &'a T) -> Self {
|
||||
fn from(reference: &T) -> Self {
|
||||
unsafe { NonNull { pointer: reference as *const T } }
|
||||
}
|
||||
}
|
||||
|
@ -850,7 +850,7 @@ impl<T, S> Default for HashSet<T, S>
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<'a, 'b, T, S> BitOr<&'b HashSet<T, S>> for &'a HashSet<T, S>
|
||||
impl<T, S> BitOr<&HashSet<T, S>> for &HashSet<T, S>
|
||||
where T: Eq + Hash + Clone,
|
||||
S: BuildHasher + Default
|
||||
{
|
||||
@ -882,7 +882,7 @@ impl<'a, 'b, T, S> BitOr<&'b HashSet<T, S>> for &'a HashSet<T, S>
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<'a, 'b, T, S> BitAnd<&'b HashSet<T, S>> for &'a HashSet<T, S>
|
||||
impl<T, S> BitAnd<&HashSet<T, S>> for &HashSet<T, S>
|
||||
where T: Eq + Hash + Clone,
|
||||
S: BuildHasher + Default
|
||||
{
|
||||
@ -914,7 +914,7 @@ impl<'a, 'b, T, S> BitAnd<&'b HashSet<T, S>> for &'a HashSet<T, S>
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<'a, 'b, T, S> BitXor<&'b HashSet<T, S>> for &'a HashSet<T, S>
|
||||
impl<T, S> BitXor<&HashSet<T, S>> for &HashSet<T, S>
|
||||
where T: Eq + Hash + Clone,
|
||||
S: BuildHasher + Default
|
||||
{
|
||||
@ -946,7 +946,7 @@ impl<'a, 'b, T, S> BitXor<&'b HashSet<T, S>> for &'a HashSet<T, S>
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<'a, 'b, T, S> Sub<&'b HashSet<T, S>> for &'a HashSet<T, S>
|
||||
impl<T, S> Sub<&HashSet<T, S>> for &HashSet<T, S>
|
||||
where T: Eq + Hash + Clone,
|
||||
S: BuildHasher + Default
|
||||
{
|
||||
|
@ -337,7 +337,7 @@ impl From<String> for Box<dyn Error> {
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<'a, 'b> From<&'b str> for Box<dyn Error + Send + Sync + 'a> {
|
||||
impl<'a> From<&str> for Box<dyn Error + Send + Sync + 'a> {
|
||||
/// Converts a [`str`] into a box of dyn [`Error`] + [`Send`] + [`Sync`].
|
||||
///
|
||||
/// # Examples
|
||||
@ -351,13 +351,13 @@ impl<'a, 'b> From<&'b str> for Box<dyn Error + Send + Sync + 'a> {
|
||||
/// assert!(
|
||||
/// mem::size_of::<Box<dyn Error + Send + Sync>>() == mem::size_of_val(&a_boxed_error))
|
||||
/// ```
|
||||
fn from(err: &'b str) -> Box<dyn Error + Send + Sync + 'a> {
|
||||
fn from(err: &str) -> Box<dyn Error + Send + Sync + 'a> {
|
||||
From::from(String::from(err))
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "string_box_error", since = "1.6.0")]
|
||||
impl<'a> From<&'a str> for Box<dyn Error> {
|
||||
impl From<&str> for Box<dyn Error> {
|
||||
/// Converts a [`str`] into a box of dyn [`Error`].
|
||||
///
|
||||
/// # Examples
|
||||
@ -370,7 +370,7 @@ impl<'a> From<&'a str> for Box<dyn Error> {
|
||||
/// let a_boxed_error = Box::<Error>::from(a_str_error);
|
||||
/// assert!(mem::size_of::<Box<dyn Error>>() == mem::size_of_val(&a_boxed_error))
|
||||
/// ```
|
||||
fn from(err: &'a str) -> Box<dyn Error> {
|
||||
fn from(err: &str) -> Box<dyn Error> {
|
||||
From::from(String::from(err))
|
||||
}
|
||||
}
|
||||
|
@ -690,8 +690,8 @@ impl<'a> From<Cow<'a, CStr>> for CString {
|
||||
}
|
||||
|
||||
#[stable(feature = "box_from_c_str", since = "1.17.0")]
|
||||
impl<'a> From<&'a CStr> for Box<CStr> {
|
||||
fn from(s: &'a CStr) -> Box<CStr> {
|
||||
impl From<&CStr> for Box<CStr> {
|
||||
fn from(s: &CStr) -> Box<CStr> {
|
||||
let boxed: Box<[u8]> = Box::from(s.to_bytes_with_nul());
|
||||
unsafe { Box::from_raw(Box::into_raw(boxed) as *mut CStr) }
|
||||
}
|
||||
@ -767,7 +767,7 @@ impl From<CString> for Arc<CStr> {
|
||||
}
|
||||
|
||||
#[stable(feature = "shared_from_slice2", since = "1.24.0")]
|
||||
impl<'a> From<&'a CStr> for Arc<CStr> {
|
||||
impl From<&CStr> for Arc<CStr> {
|
||||
#[inline]
|
||||
fn from(s: &CStr) -> Arc<CStr> {
|
||||
let arc: Arc<[u8]> = Arc::from(s.to_bytes_with_nul());
|
||||
@ -789,7 +789,7 @@ impl From<CString> for Rc<CStr> {
|
||||
}
|
||||
|
||||
#[stable(feature = "shared_from_slice2", since = "1.24.0")]
|
||||
impl<'a> From<&'a CStr> for Rc<CStr> {
|
||||
impl From<&CStr> for Rc<CStr> {
|
||||
#[inline]
|
||||
fn from(s: &CStr) -> Rc<CStr> {
|
||||
let rc: Rc<[u8]> = Rc::from(s.to_bytes_with_nul());
|
||||
@ -1268,8 +1268,8 @@ impl ToOwned for CStr {
|
||||
}
|
||||
|
||||
#[stable(feature = "cstring_asref", since = "1.7.0")]
|
||||
impl<'a> From<&'a CStr> for CString {
|
||||
fn from(s: &'a CStr) -> CString {
|
||||
impl From<&CStr> for CString {
|
||||
fn from(s: &CStr) -> CString {
|
||||
s.to_owned()
|
||||
}
|
||||
}
|
||||
|
@ -357,8 +357,8 @@ impl From<String> for OsString {
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<'a, T: ?Sized + AsRef<OsStr>> From<&'a T> for OsString {
|
||||
fn from(s: &'a T) -> OsString {
|
||||
impl<T: ?Sized + AsRef<OsStr>> From<&T> for OsString {
|
||||
fn from(s: &T) -> OsString {
|
||||
s.as_ref().to_os_string()
|
||||
}
|
||||
}
|
||||
@ -421,8 +421,8 @@ impl PartialEq<OsString> for str {
|
||||
}
|
||||
|
||||
#[stable(feature = "os_str_str_ref_eq", since = "1.29.0")]
|
||||
impl<'a> PartialEq<&'a str> for OsString {
|
||||
fn eq(&self, other: &&'a str) -> bool {
|
||||
impl PartialEq<&str> for OsString {
|
||||
fn eq(&self, other: &&str) -> bool {
|
||||
**self == **other
|
||||
}
|
||||
}
|
||||
@ -656,8 +656,8 @@ impl OsStr {
|
||||
}
|
||||
|
||||
#[stable(feature = "box_from_os_str", since = "1.17.0")]
|
||||
impl<'a> From<&'a OsStr> for Box<OsStr> {
|
||||
fn from(s: &'a OsStr) -> Box<OsStr> {
|
||||
impl From<&OsStr> for Box<OsStr> {
|
||||
fn from(s: &OsStr) -> Box<OsStr> {
|
||||
let rw = Box::into_raw(s.inner.into_box()) as *mut OsStr;
|
||||
unsafe { Box::from_raw(rw) }
|
||||
}
|
||||
@ -707,7 +707,7 @@ impl From<OsString> for Arc<OsStr> {
|
||||
}
|
||||
|
||||
#[stable(feature = "shared_from_slice2", since = "1.24.0")]
|
||||
impl<'a> From<&'a OsStr> for Arc<OsStr> {
|
||||
impl From<&OsStr> for Arc<OsStr> {
|
||||
#[inline]
|
||||
fn from(s: &OsStr) -> Arc<OsStr> {
|
||||
let arc = s.inner.into_arc();
|
||||
@ -729,7 +729,7 @@ impl From<OsString> for Rc<OsStr> {
|
||||
}
|
||||
|
||||
#[stable(feature = "shared_from_slice2", since = "1.24.0")]
|
||||
impl<'a> From<&'a OsStr> for Rc<OsStr> {
|
||||
impl From<&OsStr> for Rc<OsStr> {
|
||||
#[inline]
|
||||
fn from(s: &OsStr) -> Rc<OsStr> {
|
||||
let rc = s.inner.into_rc();
|
||||
|
@ -1456,8 +1456,8 @@ impl PathBuf {
|
||||
}
|
||||
|
||||
#[stable(feature = "box_from_path", since = "1.17.0")]
|
||||
impl<'a> From<&'a Path> for Box<Path> {
|
||||
fn from(path: &'a Path) -> Box<Path> {
|
||||
impl From<&Path> for Box<Path> {
|
||||
fn from(path: &Path) -> Box<Path> {
|
||||
let boxed: Box<OsStr> = path.inner.into();
|
||||
let rw = Box::into_raw(boxed) as *mut Path;
|
||||
unsafe { Box::from_raw(rw) }
|
||||
@ -1494,8 +1494,8 @@ impl Clone for Box<Path> {
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<'a, T: ?Sized + AsRef<OsStr>> From<&'a T> for PathBuf {
|
||||
fn from(s: &'a T) -> PathBuf {
|
||||
impl<T: ?Sized + AsRef<OsStr>> From<&T> for PathBuf {
|
||||
fn from(s: &T) -> PathBuf {
|
||||
PathBuf::from(s.as_ref().to_os_string())
|
||||
}
|
||||
}
|
||||
@ -1630,7 +1630,7 @@ impl From<PathBuf> for Arc<Path> {
|
||||
}
|
||||
|
||||
#[stable(feature = "shared_from_slice2", since = "1.24.0")]
|
||||
impl<'a> From<&'a Path> for Arc<Path> {
|
||||
impl From<&Path> for Arc<Path> {
|
||||
/// Converts a Path into a Rc by copying the Path data into a new Rc buffer.
|
||||
#[inline]
|
||||
fn from(s: &Path) -> Arc<Path> {
|
||||
@ -1650,7 +1650,7 @@ impl From<PathBuf> for Rc<Path> {
|
||||
}
|
||||
|
||||
#[stable(feature = "shared_from_slice2", since = "1.24.0")]
|
||||
impl<'a> From<&'a Path> for Rc<Path> {
|
||||
impl From<&Path> for Rc<Path> {
|
||||
/// Converts a Path into a Rc by copying the Path data into a new Rc buffer.
|
||||
#[inline]
|
||||
fn from(s: &Path) -> Rc<Path> {
|
||||
|
@ -297,10 +297,10 @@ impl Iterator for LookupHost {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> TryFrom<&'a str> for LookupHost {
|
||||
impl TryFrom<&str> for LookupHost {
|
||||
type Error = io::Error;
|
||||
|
||||
fn try_from(_v: &'a str) -> io::Result<LookupHost> {
|
||||
fn try_from(_v: &str) -> io::Result<LookupHost> {
|
||||
unsupported()
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ impl Iterator for LookupHost {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> TryFrom<&'a str> for LookupHost {
|
||||
impl TryFrom<&str> for LookupHost {
|
||||
type Error = io::Error;
|
||||
|
||||
fn try_from(s: &str) -> io::Result<LookupHost> {
|
||||
|
@ -420,10 +420,10 @@ impl Iterator for LookupHost {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> TryFrom<&'a str> for LookupHost {
|
||||
impl TryFrom<&str> for LookupHost {
|
||||
type Error = io::Error;
|
||||
|
||||
fn try_from(v: &'a str) -> io::Result<LookupHost> {
|
||||
fn try_from(v: &str) -> io::Result<LookupHost> {
|
||||
LookupHost::new(v.to_owned())
|
||||
}
|
||||
}
|
||||
|
@ -447,10 +447,10 @@ pub mod net {
|
||||
unsafe impl Send for LookupHost {}
|
||||
|
||||
|
||||
impl<'a> TryFrom<&'a str> for LookupHost {
|
||||
impl TryFrom<&str> for LookupHost {
|
||||
type Error = io::Error;
|
||||
|
||||
fn try_from(_v: &'a str) -> io::Result<LookupHost> {
|
||||
fn try_from(_v: &str) -> io::Result<LookupHost> {
|
||||
unimpl!();
|
||||
}
|
||||
}
|
||||
|
@ -298,10 +298,10 @@ impl Iterator for LookupHost {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> TryFrom<&'a str> for LookupHost {
|
||||
impl TryFrom<&str> for LookupHost {
|
||||
type Error = io::Error;
|
||||
|
||||
fn try_from(_v: &'a str) -> io::Result<LookupHost> {
|
||||
fn try_from(_v: &str) -> io::Result<LookupHost> {
|
||||
unsupported()
|
||||
}
|
||||
}
|
||||
|
@ -157,7 +157,7 @@ impl Drop for LookupHost {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> TryFrom<&'a str> for LookupHost {
|
||||
impl TryFrom<&str> for LookupHost {
|
||||
type Error = io::Error;
|
||||
|
||||
fn try_from(s: &str) -> io::Result<LookupHost> {
|
||||
|
Loading…
Reference in New Issue
Block a user