Skip to content

Add pin_ptr macro #4

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

Merged
merged 6 commits into from
Feb 24, 2025
Merged

Add pin_ptr macro #4

merged 6 commits into from
Feb 24, 2025

Conversation

JR-1991
Copy link
Member

@JR-1991 JR-1991 commented Feb 24, 2025

This PR adds a macro to streamline the typical pinning process upon initialization of an SBML struct. Effectively, the process reduces the following way:

// From this
let species_ptr: &mut sbmlcxx::Species = unsafe { &mut *some_ptr }
let species = unsafe { Pin::new_unchecked(ref_ptr) }

// To this
let mut species = pin_ptr!(species_ptr, sbmlcxx::Species);

While this is a minor change it streamlines the unsafe process and possibly prevents misuse of unsafe code in other places.

@JR-1991 JR-1991 merged commit 5db6d8d into master Feb 24, 2025
3 checks passed
@JR-1991 JR-1991 deleted the pin-ref-macro-init branch February 24, 2025 09:50
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.

1 participant