Skip to content

Commit 313f791

Browse files
elmarcowhitequark
authored andcommitted
Do not constrain Owned variants to 'static lifetime.
This unnecessarily restricts the contents of the container to have a 'static lifetime, even if otherwise there is no such requirement.
1 parent 1aa1cd6 commit 313f791

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/object.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use alloc::vec::Vec;
2525
/// argument; then, it will be possible to pass either a `Box<T>`, `Vec<T>`, or a `&'a mut T`
2626
/// without any conversion at the call site.
2727
///
28-
/// Note that a `Vec<T>` converted into an `Into<Managed<'static, [T]>>` gets transformed
28+
/// Note that a `Vec<T>` converted into an `Into<Managed<'a, [T]>>` gets transformed
2929
/// into a boxed slice, and can no longer be resized. See also
3030
/// [ManagedSlice](enum.ManagedSlice.html), which does not have this drawback.
3131
pub enum Managed<'a, T: 'a + ?Sized> {
@@ -54,14 +54,14 @@ impl<'a, T: 'a + ?Sized> From<&'a mut T> for Managed<'a, T> {
5454
}
5555

5656
#[cfg(any(feature = "std", feature = "alloc"))]
57-
impl<T: ?Sized + 'static> From<Box<T>> for Managed<'static, T> {
57+
impl<'a, T: ?Sized + 'a> From<Box<T>> for Managed<'a, T> {
5858
fn from(value: Box<T>) -> Self {
5959
Managed::Owned(value)
6060
}
6161
}
6262

6363
#[cfg(any(feature = "std", feature = "alloc"))]
64-
impl<T: 'static> From<Vec<T>> for Managed<'static, [T]> {
64+
impl<'a, T: 'a> From<Vec<T>> for Managed<'a, [T]> {
6565
fn from(value: Vec<T>) -> Self {
6666
Managed::Owned(value.into_boxed_slice())
6767
}

src/slice.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ from_unboxed_slice!(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
7171
16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31);
7272

7373
#[cfg(any(feature = "std", feature = "alloc"))]
74-
impl<T: 'static> From<Vec<T>> for ManagedSlice<'static, T> {
74+
impl<'a, T: 'a> From<Vec<T>> for ManagedSlice<'a, T> {
7575
fn from(value: Vec<T>) -> Self {
7676
ManagedSlice::Owned(value)
7777
}

0 commit comments

Comments
 (0)