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
{{ message }}
Repository navigation
Don't use 'a for the underlying slice's lifetime #331
I'd like to make a proposal, just so I don't go implement it without having consensus on it being fine. Since 'a is kinda the default generic lifetime name, it's kinda annoying that it's also the one used for the "god slice" as I call it, the big &[u8] underlying a Reader. This makes that when a "ad-hoc temporary" lifetime is chosen, we will either (1) have to come up with another name because 'a is also used in the same context, or (2) use 'a with another meaning than all other 'as in the code.
So I'd like to propose using some kind of two-character lifetime name to indicate that it's a more permanent and cross-signature lifetime than 'a. Possible proposed names would be 'sl (for slice), or 'in (for input), or 'bf (for buffer), ...
I'd be wiling to do the work to use it everywhere, it helps me with the work I'm doing with fixing the borrows everywhere.
Doing this would probably have avoided bug #332, f.e. as that is an example where 'a is used and it looks like it refers to the "god slice" lifetime, but is not.
I really don't mind changing the lifetime names, in particular if it can avoid some bugs.
I tend to prefer bf but feel free to pick another one, it'll always be better than 'a
Yeah my only concern with 'bf is that it might be ambiguous since there is the &[u8] that is used as input, but for the buffered logic, there is also the buf: &mut Vec<u8>. So maybe we should use 'bf for things that borrow from that (explicitly so named) buffer and something like 'in for the input slice.
Activity
stevenroose commentedon Oct 25, 2021
Doing this would probably have avoided bug #332, f.e. as that is an example where
'ais used and it looks like it refers to the "god slice" lifetime, but is not.tafia commentedon Oct 26, 2021
I really don't mind changing the lifetime names, in particular if it can avoid some bugs.
I tend to prefer
bfbut feel free to pick another one, it'll always be better than'astevenroose commentedon Oct 26, 2021
Yeah my only concern with
'bfis that it might be ambiguous since there is the&[u8]that is used as input, but for the buffered logic, there is also thebuf: &mut Vec<u8>. So maybe we should use'bffor things that borrow from that (explicitly so named) buffer and something like'infor the input slice.