Closed blainehansen closed 1 year ago
Base: 60.52% // Head: 60.60% // Increases project coverage by +0.08%
:tada:
Coverage data is based on head (
4a246f2
) compared to base (6cecd1a
). Patch coverage: 100.00% of modified lines in pull request are covered.
:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
I thought you would consider the possible panics acceptable since the
Modify
implementation does the same thing. It seems this is safe to do, since the borrow only lasts during the function's synchronous call and won't conflict with other borrows sinceRc
can't be sent across thread boundaries.
Just for reference, the current Modify
implementation can't panic because it creates a clone implicitly behind the hood. However, that being said, I would probably still consider this possible panic acceptable.
This doesn't actually reliably work, I just tried to use it in a fairly simple case and it panicked. I'll close and open another pr if I can get this to work ha.
This doesn't actually reliably work, I just tried to use it in a fairly simple case and it panicked. I'll close and open another pr if I can get this to work ha.
I think to make this work, we would need to either get rid of the inner Rc
in RefCell<Rc>
or add another nested RefCell
so RefCell<Rc<RefCell>>
. I am personally leaning towards the former. I've been thinking maybe we can just make .get()
only work for Copy
types and add a .read()
which wraps around RefCell::borrow
and a similar .write()
. We could also add a .get_clone()
which would be an alias for .read().as_ref().clone()
.
So to get the original behavior for Signal
back, you'll need to add a Rc::new(value)
to all the create_signal
s and use .get_clone()
instead of .get()
.
Sadly, this would be a really massive breaking change again but I think it could be worth it.
More convenience functions :) These
set_fn_mut
variants useRefCell::borrow_mut
andRc::get_mut
to directly mutably borrow the underlying value without a clone.I thought you would consider the possible panics acceptable since the
Modify
implementation does the same thing. It seems this is safe to do, since the borrow only lasts during the function's synchronous call and won't conflict with other borrows sinceRc
can't be sent across thread boundaries.Am I crazy? There are tests covering it even with dependent signals, so it seems safe!