You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
error[E0308]: mismatched types
--> src/main.rs:14:5
|
14 | input.into_owned()
| ^^^^^^^^^^^^^^^^^^ lifetime mismatch
|
= note: expected struct `Example<'a>`
found struct `Example<'static>`
note: the lifetime `'a` as defined on the function body at 13:14...
--> src/main.rs:13:14
|
13 | fn transform<'a>(input: Example<'a>) -> Example<'a> {
| ^^
= note: ...does not necessarily outlive the static lifetime
error: aborting due to previous error
which does compile when you replace SmallVec with Vec.
This works with Vec, because internally the pointer is wrapped in Unique<T>:
I could not get the following code to compile with
SmallVec
(I heavily simplified the code):playground
which does compile when you replace
SmallVec
withVec
.This works with
Vec
, because internally the pointer is wrapped inUnique<T>
:https://github.com/rust-lang/rust/blob/fb5615a4771ea3d54256f969dc84d2dfd38d812c/src/liballoc/raw_vec.rs#L47
whereas
SmallVec
contains a raw pointer:rust-smallvec/lib.rs
Line 370 in a541e2d
This issue can be solved by changing
*mut A::Item
toOption<NonNull<A::Item>>
, becauseNonNull
implements theCoerceUnsized
trait.This might be related to #146
The text was updated successfully, but these errors were encountered: