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

Correct lifetimes for borrowing of dart slice *parameters* #430

Merged
merged 7 commits into from
Feb 22, 2024

Conversation

Manishearth
Copy link
Contributor

@Manishearth Manishearth commented Feb 21, 2024

Progress on #421, using approach from #406 (comment)

This does not yet handle slices in structs, but it's relatively self contained so I figured I'd make an early PR.

Part of #439

// and also ensure it's not destroyed.
format!("{param_name}View")
// Slices make an arena with a finalizer that needs to be attached
format!("{param_name}Arena")
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we are doing one arena per parameter we might as well do the same as in JS where we attach finalizers that free using diplomat_free

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What's the difference? Both allocate in the native heap, yes?

Also it's one arena per parameter that gets borrowed in the output. It's going to be rare.

I don't think it's a good idea to have two separate paths for slice construction based on arenas or native rust allocation: the way this is designed all slices need for conversion is an arena, it can be a temporary one or a finalized one.

tool/templates/dart/init.dart Outdated Show resolved Hide resolved
Manishearth and others added 3 commits February 22, 2024 06:17
Co-authored-by: Robert Bastian <4706271+robertbastian@users.noreply.github.com>
@Manishearth Manishearth merged commit 6d1265d into rust-diplomat:main Feb 22, 2024
6 checks passed
@Manishearth Manishearth deleted the dart-borrow-slice branch February 26, 2024 17:20
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