Skip to content

Commit

Permalink
Box fragile in semisticky
Browse files Browse the repository at this point in the history
  • Loading branch information
mitsuhiko committed Oct 18, 2022
1 parent fcadbc5 commit cf5169d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/semisticky.rs
Expand Up @@ -7,7 +7,7 @@ use crate::sticky::Sticky;
use std::mem;

enum SemiStickyImpl<T: 'static> {
Fragile(Fragile<T>),
Fragile(Box<Fragile<T>>),
Sticky(Sticky<T>),
}

Expand Down Expand Up @@ -36,7 +36,7 @@ impl<T> SemiSticky<T> {
inner: if mem::needs_drop::<T>() {
SemiStickyImpl::Sticky(Sticky::new(value))
} else {
SemiStickyImpl::Fragile(Fragile::new(value))
SemiStickyImpl::Fragile(Box::new(Fragile::new(value)))
},
}
}
Expand Down Expand Up @@ -72,7 +72,7 @@ impl<T> SemiSticky<T> {
pub fn try_into_inner(self) -> Result<T, Self> {
match self.inner {
SemiStickyImpl::Fragile(inner) => inner.try_into_inner().map_err(|inner| SemiSticky {
inner: SemiStickyImpl::Fragile(inner),
inner: SemiStickyImpl::Fragile(Box::new(inner)),
}),
SemiStickyImpl::Sticky(inner) => inner.try_into_inner().map_err(|inner| SemiSticky {
inner: SemiStickyImpl::Sticky(inner),
Expand Down

0 comments on commit cf5169d

Please sign in to comment.