How do you create a generic function in Rust with a trait requiring a lifetime?
问题 I am trying to write a trait which works with a database and represents something which can be stored. To do this, the trait inherits from others, which includes the serde::Deserialize trait. trait Storable<'de>: Serialize + Deserialize<'de> { fn global_id() -> &'static [u8]; fn instance_id(&self) -> Vec<u8>; } struct Example { a: u8, b: u8 } impl<'de> Storable<'de> for Example { fn global_id() -> &'static [u8] { b"p" } fn instance_id(&self) -> Vec<u8> { vec![self.a, self.b] } } Next, I am