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

Remapped the lifetimes of FFISlice and FFISliceMut a bit. #107

Merged

Conversation

Earthmark
Copy link
Contributor

This allows FFISlice and FFISliceMut to 'leak' a slice of the backing data, even though the returned slice has a valid actual lifetime.

This allows FFISlice to be a pass-through through type.

This allows FFISlice and FFISliceMut to 'leak' a slice of the backing data, even though the returned slice has a valid actual lifetime.

This allows FFISlice to be a pass-through through type.
fn multi_borrow_mut_slice() {
let slice = &mut [0, 1, 2, 3, 5];
let empty = FFISliceMut::<u8>::empty();
let target: &mut [u8] = {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Trying to borrow slice again results in a complier error, this is still a safe piece of code because the original slice is the scope of mutation, not the intermediate FFISliceMut.

@ralfbiedert
Copy link
Owner

Thanks!

@ralfbiedert ralfbiedert merged commit 57ba53d into ralfbiedert:master Jun 29, 2024
1 check passed
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