creusot icon indicating copy to clipboard operation
creusot copied to clipboard

Specify `String::as_mut_vec`?

Open Lysxia opened this issue 7 months ago • 2 comments

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

Issue split from https://github.com/creusot-rs/creusot/issues/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 avatar Apr 24 '25 14:04 Lysxia

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

Lysxia avatar Apr 24 '25 14:04 Lysxia

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

jhjourdan avatar Apr 30 '25 19:04 jhjourdan