uazu / qcell

Statically-checked alternatives to RefCell and RwLock
Apache License 2.0
356 stars 22 forks source link

`rwn` to borrow `N` cells #49

Open Ddystopia opened 3 months ago

Ddystopia commented 3 months ago

Hello,

can here be an api like that in std? So that signature would look like

pub fn rwn<'a, T: ?Sized, const N: usize>(&'a mut self, qc: [&'a QCell<T>; N]) -> [&'a mut T; N];
uazu commented 3 months ago

I'm just catching up. Do you have a particular use-case for this? Just so that I can understand the motivation.

There is no guarantee that these references are distinct, so it will need an O(n^2) cross-check. I was working on a prototype API for borrowing an unlimited number of things simultaneously, but other things took precedence. That would have been adding one borrow at a time in the code, with an O(N) check for each, so not exactly this API.