Skip to content

Cannot derive WrappedVec if I need lifetime specifiers #7

Description

@mildsenseofdoom

I.e. this doesn't work, which I'd like to be able to use:

#[derive(wrapped_vec::WrappedVec)]
#[CollectionName = "Collection"]
struct Struct<'a> {
    var: &'a str,
}

This gives the following error:

error[E0106]: missing lifetime specifier
  --> src/lib.rs:15:8
   |
15 | struct Struct<'a> {
   |        ^^^^^^ expected named lifetime parameter
   |
help: consider introducing a named lifetime parameter
   |
13 ~ #[derive(wrapped_vec::WrappedVec<'a>)]
14 | #[CollectionName = "Collection"]
15 ~ struct Struct<'a><'a> {
   |

The suggestion does not work, and the intuitive-to-me idea of adding the specifier in the CollectionName does not work because WrappedVec doesn't seem to recognise the lifetime specifier as valid:

#[derive(wrapped_vec::WrappedVec)]
#[CollectionName = "Collection<'a>"]
struct Struct<'a> {
    var: &'a str,
}

Gives:

error: proc-macro derive panicked
  --> src/lib.rs:13:10
   |
13 | #[derive(wrapped_vec::WrappedVec)]
   |          ^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: message: `"Collection<'a>"` is not a valid identifier

I tried looking in the documentation for how to do this but it wasn't marked, so if I missed it then maybe a reference in the error message would help people in future.

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