Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Use Cow<[T]> instead of Vec<T> where possible. #240

Closed
duesee opened this issue Jun 3, 2023 · 1 comment · Fixed by #243
Closed

feat: Use Cow<[T]> instead of Vec<T> where possible. #240

duesee opened this issue Jun 3, 2023 · 1 comment · Fixed by #243
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@duesee
Copy link
Owner

duesee commented Jun 3, 2023

@duesee duesee added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Jun 3, 2023
@duesee
Copy link
Owner Author

duesee commented Jun 5, 2023

This is harder than expected. Changing, e.g., Data::List { items: Vec<FlagNameAttribute<'a>> } to Data::List { items: Cow<'a, [FlagNameAttribute<'a>]> } results in the error message "the enum Cow<'a, B> is invariant over the parameter B".

I think what happens is that Cow::to_static(...) yields Vec<FlagNameAttribute<'a>> which isn't bounded by `'static'.

// $ cargo expand --features bounded-static

// ...

Data::List { items, delimiter, mailbox } => {
  Data::List {
      items: items.to_static(),
      delimiter: delimiter.to_static(),
      mailbox: mailbox.to_static(),
  }
}

// ...

@duesee duesee added this to the M5 - Release imap-codec 1.0.0 milestone Jun 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant