Skip to content

Commit 39f4150

Browse files
Add From impls for wrapper types
- `From<T> for ThinBox<T>` - `From<T> for UniqueRc<T>` - `From<T> for UniqueArc<T>` - `From<T> for ManuallyDrop<T>` - `From<T> for AssertUnwindSafe<T>`
1 parent fe55364 commit 39f4150

File tree

5 files changed

+40
-0
lines changed

5 files changed

+40
-0
lines changed

library/alloc/src/boxed/thin.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,3 +430,11 @@ impl<T: ?Sized + Error> Error for ThinBox<T> {
430430
self.deref().source()
431431
}
432432
}
433+
434+
#[unstable(feature = "thin_box", issue = "92791")]
435+
impl<T> From<T> for ThinBox<T> {
436+
#[inline(always)]
437+
fn from(value: T) -> Self {
438+
Self::new(value)
439+
}
440+
}

library/alloc/src/rc.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3816,6 +3816,14 @@ impl<T: ?Sized, A: Allocator> AsMut<T> for UniqueRc<T, A> {
38163816
#[unstable(feature = "unique_rc_arc", issue = "112566")]
38173817
impl<T: ?Sized, A: Allocator> Unpin for UniqueRc<T, A> {}
38183818

3819+
#[unstable(feature = "unique_rc_arc", issue = "112566")]
3820+
impl<T> From<T> for UniqueRc<T> {
3821+
#[inline(always)]
3822+
fn from(value: T) -> Self {
3823+
Self::new(value)
3824+
}
3825+
}
3826+
38193827
#[unstable(feature = "unique_rc_arc", issue = "112566")]
38203828
impl<T: ?Sized + PartialEq, A: Allocator> PartialEq for UniqueRc<T, A> {
38213829
/// Equality for two `UniqueRc`s.

library/alloc/src/sync.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4242,6 +4242,14 @@ impl<T: ?Sized, A: Allocator> AsMut<T> for UniqueArc<T, A> {
42424242
}
42434243
}
42444244

4245+
#[unstable(feature = "unique_rc_arc", issue = "112566")]
4246+
impl<T> From<T> for UniqueArc<T> {
4247+
#[inline(always)]
4248+
fn from(value: T) -> Self {
4249+
Self::new(value)
4250+
}
4251+
}
4252+
42454253
#[unstable(feature = "unique_rc_arc", issue = "112566")]
42464254
impl<T: ?Sized, A: Allocator> Unpin for UniqueArc<T, A> {}
42474255

library/core/src/mem/manually_drop.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,3 +276,11 @@ impl<T: ?Sized> DerefMut for ManuallyDrop<T> {
276276

277277
#[unstable(feature = "deref_pure_trait", issue = "87121")]
278278
unsafe impl<T: ?Sized> DerefPure for ManuallyDrop<T> {}
279+
280+
#[stable(feature = "from_wrapper_impls", since = "CURRENT_RUSTC_VERSION")]
281+
impl<T> From<T> for ManuallyDrop<T> {
282+
#[inline(always)]
283+
fn from(value: T) -> Self {
284+
Self::new(value)
285+
}
286+
}

library/core/src/panic/unwind_safe.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,3 +311,11 @@ impl<S: AsyncIterator> AsyncIterator for AssertUnwindSafe<S> {
311311
self.0.size_hint()
312312
}
313313
}
314+
315+
#[stable(feature = "from_wrapper_impls", since = "CURRENT_RUSTC_VERSION")]
316+
impl<T> From<T> for AssertUnwindSafe<T> {
317+
#[inline(always)]
318+
fn from(value: T) -> Self {
319+
Self(value)
320+
}
321+
}

0 commit comments

Comments
 (0)