Change &'a T to Borrow<'a,T> and &'a mut T to BorrowMut<'a,T>


Current Rust has not HKT (a.k.a Higher Kinded type) support.

With HKT being implemented in the future, we can write something like fn produce_ref<'a,R,T>(a: &'a SomeType) -> R<T> , where R can be Rc or Box or Arc etc, but R cannot be an & because we cant represent & borrow in the R<T> form.

So, what about change & borrow to Borrow<T> and &mut to BorrowMut<T>, and make &/&mut syntax be a syntax surgar of Borrow<T>/BorrowMut<T> ? It is more symmetric and HTK friendly.


This would be rather ugly. Also, there are other interesting types that you can’t put into a simple A<T> form, for example Rc<RefCell<Vec<T>>> – when we implement HKT, we should probably allow using type-aliases as HKT-s, so you could simple have type Borrow<'a, T> = &'a T;.

closed #3

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.