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

Change syntax for blocks, and allow them to carry a lifetime #569

Merged
merged 1 commit into from
Feb 2, 2024

Conversation

madsmtm
Copy link
Owner

@madsmtm madsmtm commented Jan 25, 2024

Part of #168.

Change the syntax to Block<dyn Fn(Args) -> R>, which more clearly describes the required signature, and allows us to introduce lifetimes to correctly mark noescape/NS_NOESCAPE blocks, and make functions taking those safe.

// Before
fn takes_block(block: &Block<(u32,), u8>) { ... }
unsafe fn takes_noescape_block(block: &Block<(u32, u32), ()>) { ... }

// After
fn takes_block(block: &Block<dyn Fn(u32) -> u8>) { ... }
fn takes_noescape_block(block: &Block<dyn Fn(u32, u32) + '_>) { ... }

@madsmtm madsmtm added enhancement New feature or request A-block2 Affects the `block2` crate labels Jan 25, 2024
@madsmtm madsmtm force-pushed the block-dyn-fn branch 7 times, most recently from ec7c8f1 to 00880d2 Compare January 30, 2024 21:40
@madsmtm madsmtm marked this pull request as ready for review January 30, 2024 21:41
@madsmtm madsmtm force-pushed the block-dyn-fn branch 3 times, most recently from 15dc1b2 to d8cb01e Compare February 2, 2024 11:21
@madsmtm madsmtm merged commit 415a6c6 into master Feb 2, 2024
19 checks passed
@madsmtm madsmtm deleted the block-dyn-fn branch February 2, 2024 12:04
@madsmtm madsmtm mentioned this pull request Feb 2, 2024
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-block2 Affects the `block2` crate enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant