yewstack/yewtil

Explore utility of an UnsafeRc

hgzimmerman opened this issue · 0 comments

There may be utility in creating an Rc-like pointer that when calling as_mut or other mutating functions, does not clone the value it points to to ensure unique ownership. The invariant that would need to be upheld is that no references could be held to values owned by the ptr. Because of Yew's distaste for component lifetimes other than 'static, this may already be impossible to violate within expected operation of Yew.
Nonetheless, any mutating function that would otherwise clone in Mrc should be marked as unsafe to indicate that that particular invariant must be upheld. This would have impacts on ergonomics, but this sort of ability shouldn't be used in application code, and would find its use in component libraries as an optimization invisible to the outside world.