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 stack-allocated trait object #16

Merged
merged 1 commit into from
Jun 21, 2024

Conversation

gabyx
Copy link
Contributor

@gabyx gabyx commented Jun 21, 2024

Proposed Changes

  • It is possible to create a wide-pointer to a trait object on the stack with newer Rust. This is possible because there is a feature called lifetime extension.
  • Use this in the current code.

Types of Changes

What types of changes does your code introduce? Put an x in the boxes that
apply

  • A bug fix (non-breaking change which fixes an issue).
  • A new feature (non-breaking change which adds functionality).
  • A breaking change (fix or feature that would cause existing
    functionality to not work as expected).
  • A non-productive update (documentation, tooling, etc. if none of the
    other choices apply).

Checklist

Put an x in the boxes that apply. You can also fill these out after creating
the PR. If you're unsure about any of them, don't hesitate to ask. We're here to
help! This is simply a reminder of what we are going to look for before merging
your code.

  • I have read the
    CONTRIBUTING
    guidelines.
  • I have added tests that prove my fix is effective or that my feature
    works.
  • I have added the necessary documentation (if appropriate).

Further Comments

Something I learned at the RustFest. =)

- It is possible to create a wide-pointer to a trait
  object on the stack with newer Rust. This is possible because
  there is a feature called *lifetime extension*.

Signed-off-by: Gabriel Nützi <gnuetzi@gmail.com>
@gabyx gabyx requested a review from cmdoret June 21, 2024 11:45
Copy link
Member

@cmdoret cmdoret left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! This is also more readable 👍

@cmdoret cmdoret merged commit 66c0fac into main Jun 21, 2024
@cmdoret cmdoret deleted the feat/dyn-dispatch-on-the-stack branch June 21, 2024 14:48
supermaxiste pushed a commit that referenced this pull request Jun 24, 2024
Signed-off-by: Gabriel Nützi <gnuetzi@gmail.com>
supermaxiste pushed a commit that referenced this pull request Jun 24, 2024
Signed-off-by: Gabriel Nützi <gnuetzi@gmail.com>
supermaxiste pushed a commit that referenced this pull request Jun 24, 2024
Signed-off-by: Gabriel Nützi <gnuetzi@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants