pub fn buffer(&self) -> &'a [u8] instead of pub fn buffer(&'a self) -> &'a [u8]. &'a is the lifetime of the underlying buffer, not the Pdu struct. Borrowing self as &'a self does something funky (i do not understand lifetimes well enough to say exactly what) with the &'a lifetime and limits the lifetime of the return value to the lifetime of the struct. For example
gives the error "error[E0515]: cannot return value referencing local variable v4" with pdu 1.4.2, but it compiles when pointed at a fork (https://github.com/tsheinen/pdu) where i just find-and-replaced every &'a self with &self.
pub fn buffer(&self) -> &'a [u8]
instead ofpub fn buffer(&'a self) -> &'a [u8]
. &'a is the lifetime of the underlying buffer, not the Pdu struct. Borrowing self as &'a self does something funky (i do not understand lifetimes well enough to say exactly what) with the &'a lifetime and limits the lifetime of the return value to the lifetime of the struct. For examplegives the error "error[E0515]: cannot return value referencing local variable
v4
" with pdu 1.4.2, but it compiles when pointed at a fork (https://github.com/tsheinen/pdu) where i just find-and-replaced every &'a self with &self.