This crate impements a slice that can seal parts of itself off from mutability, and hand out the sealed parts as immutable references.
This is a very small crate, with only about a dozen lines of effective code.
It is still provided in a dedicated crate to clearly encapsulate the guarantees of this crate from whatever uses it, and to provide some testing and stability, as opposed to ad-hoc implementations of the same concept.
This crate should be versioned as 1.0 soon, given there's not much interface that can change.
Variations that were considered on the API:
Implement the Index and IndexMut operation on the SealingSlice. Access via an immutable indexing would panic out-of-bounds when access after the seal is attempted (especially via the end-open interval for a not-completely-sealed slice), and mutable indexing would similarly err out if sealed areas are accessed.
For users that access mutable areas at fixed offsets, this would mean less calculating their position in the current mutable view.
Implementation would, line-of-code-wise, exceed the current code, as all variations of Range, RangeFrom, RangeToInclusive etc. would need to be covered.
Have an interface where sealing consumes the sealing slice, and a new sealing slice with no knowledge of any left-off parts is created. Should work lifetime-wise, and looks more like a peek-and-edit-able reader.
That route could be promising as it'd avoid some run-time checks.
The former can still be implemented with this crate stabilizing; the latter is probably too different and could need to be implemented separately.