pub enum Entry<'a, V, O>
where
V: Vacant<'a> + 'a,
O: Occupied<'a> + 'a,
{
Vacant(V),
Occupied(O),
}
pub trait Vacant<'a> {
fn insert(self, value: Vec<u8>) -> &'a mut [u8];
}
pub trait Occupied<'a> {
fn insert(self, value: Vec<u8>) -> &'a mut [u8];
}
fn main() {}
Compiling playground v0.0.1 (/playground)
error[E0392]: parameter `'a` is never used
--> src/main.rs:1:16
|
1 | pub enum Entry<'a, V, O>
| ^^ unused parameter
|
= help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData`
For more information about this error, try `rustc --explain E0392`.
error: could not compile `playground` due to previous error
I want create a custom Entry
type like in BTreeMap, but left the Vacant/Occupied as a trait bounded lifetime 'a so that users can provide their Entry implementions used in different containers. How can I compile enum type Entry
successfully ? If I was using struct type EntryStruct
, it would be easy with std::marker::PhantomData<&'a ()>
, but I cannot do in enum type .