Skip to content

Specify String::as_mut_vec? #1482

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

Open
Lysxia opened this issue Apr 24, 2025 · 2 comments
Open

Specify String::as_mut_vec? #1482

Lysxia opened this issue Apr 24, 2025 · 2 comments
Labels
enhancement New feature or request

Comments

@Lysxia
Copy link
Collaborator

Lysxia commented Apr 24, 2025

impl String {
  unsafe fn as_mut_vec(&mut self) -> &mut Vec<u8>
}

Issue split from #1379

Ideally some post_requires clause would exist (factoring out the requirements into a predicate to use it both in the ensures and post_requires clauses).

This is what we refer to as "after_expiry" or a pledge

@Lysxia
Copy link
Collaborator Author

Lysxia commented Apr 24, 2025

I wonder if we can use CPS as a workaround?

unsafe fn with_mut_vec(&mut self, k: for<'a> impl FnOnce(&'a mut Vec<u8>) -> R) -> R

@jhjourdan
Copy link
Collaborator

This is definitely an option indeed, even though on the long term I would prefer supporting open borrows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants