Skip to content

Don't use 'a for the underlying slice's lifetime #331

Closed

Description

@stevenroose

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.

Activity

  1. stevenroose commented on Oct 25, 2021

    @stevenroose
    Author

    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.

  2. tafia commented on Oct 26, 2021

    @tafia
    Owner

    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

  3. stevenroose commented on Oct 26, 2021

    @stevenroose
    Author

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions