t: Pin<&'t mut T>,
) -> Self { .. }
- pub fn ref_(self, g: &'a NoAlias) -> &'a T { .. }
+ pub fn borrow(self, g: &NoAlias) -> Ref<T> { .. }
- pub fn mut_(self, g: &'a NoAlias) -> &'a mut T {
- // SAFETY
- //
- // 1.
- ..
- }
+ pub fn borrow_mut(self, g: &mut NoAlias) -> RefMut<T> { .. }
/// # SAFETY
///
///
/// ("used" means passed to any method in this library).
///
- /// (The compiler will check that no borrows
- pub unsafe fn free<'g: 'a>(self, : &'g mut NoAlias) { .. }
+ /// (The compiler will check that no borrows are live.)
+ pub unsafe fn free(self, g: &mut NoAlias) { .. }
+}
+
+impl<T> Deref for Ref<T> {
+ type Target = T;
+}
+impl<T> DerefMut for RefMut<T> {
+ type Target = T;
+}
+
+struct MultiAccessor<'a, R, const N: usize> {
}
impl NoAlias {
/// # SAFETY
///
- /// You must ensure that there is only ever one
- /// `NoAlias` within the whole program.
- pub unsafe fn new() -> Self { .. }
-
- pub fn scope(f: impl FnOnce(&mut NoAlias) -> R) -> R {
- /// SAFETY
- ///
- /// `f` doesn't control the lifetime -
- /// as far as it's concerned, is independent from any other
- /// So it can't mix up *this* NoAlias with any other.
- let g = unsafe { NoAlias::new() };
- f(g)
- }
-
- pub fn multi_ref<'aa>(
- &'aa mut self,
- ref_: [
+ /// There must be only one `NoAlias` used with each `Ptr`.
+ ///
+ /// That is, it is unsound to use the same `Ptr` (or any copy of it)
+ /// with two (or more) different `NoAlias`es.
+ ///
+ /// The easiest way to do this is to have only one `NoAlias`.
+ ///
+ /// If this rule is violated, `borrow` and `borrow_mut` can be instant-UB.
+ //
+ // I haven't been able to think of a practical safe API,
+ // but one only needs about 1 call to init_unchecked.
+ pub unsafe fn init_unchecked() -> Self { .. }
+
+ pub fn multi(&mut self) -> MultiAccessor<(), 0> { .. }
+}
+
+impl MultiAccessor<'a, R, const N: usize> {
+ pub fn finish(self) -> R { .. }
+
+ pub fn borrow<T>(self, p:
- pub fn multi<'aa: 'a>(self, arena: &'aa mut NoAlias) -> &mut { .. }
pub fn add(left: u64, right: u64) -> u64 {
left + right