Skip to content

Disallow mut ref to inner Vec for NEVec, allow ref and mut ref to slice#51

Open
MOZGIII wants to merge 1 commit into
fosskers:masterfrom
MOZGIII:bad-mut
Open

Disallow mut ref to inner Vec for NEVec, allow ref and mut ref to slice#51
MOZGIII wants to merge 1 commit into
fosskers:masterfrom
MOZGIII:bad-mut

Conversation

@MOZGIII

@MOZGIII MOZGIII commented Mar 17, 2026

Copy link
Copy Markdown

Allowing mut access to inner Vec much allows breaking the non-emptyness invariant.

Allowing mut access to inner Vec much allows breaking
the non-emptyness invariant.
@MOZGIII

MOZGIII commented Mar 17, 2026

Copy link
Copy Markdown
Author

@fosskers there's more work to do in this domain, like NESet also needs to be cleaned up and etc - but first I'd like your feedback on this.

@fosskers

fosskers commented Apr 25, 2026

Copy link
Copy Markdown
Owner

Can you provide a code example that demonstrates the invariant being violated?

@MOZGIII

MOZGIII commented Apr 26, 2026

Copy link
Copy Markdown
Author
let mut nevec: NEVec<u8> = ...;

let vecmut: &mut Vec<u8> = nevec.as_mut();

*vecmut = vec![];

@fosskers

Copy link
Copy Markdown
Owner

Thanks, I'll test with this.

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