Ways to improve my crate?

I created a crate called borrow_trait, which provides 2 traits for immutably and mutably borrowing from different kinds of RefCells and wrappers like Arc<RefCell>.
I am not sure if there is anything I can improve or add :confused:

struct AcceptsBound<'a, C, T>
where
    T: BorrowRef<'a, Target = C>,
    C: Read
{
    value: T,
    _c: PhantomData<&'a C>,
}
let value = AcceptsBound {
   value: Cursor::new(vec![]),
   _c: PhantomData
}
1 Like

Instead of implementing for &T and &mut T directly, you can use blanket impls that forward to T, like this,

impl<'a, 'b: 'a, T: 'a + BorrowRef<'a>> BorrowRef<'a> for &'b T {
    ...
}
1 Like

Arc<RefCell<T>> is not Send as RefCell<T> is not Send, so it's not more useful than Rc<RefCell<T>>. But it still increment/decrement its counter with atomic operation which comes with its cost, while guaranteed to be single thread access.

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