In Rust, it's common to explicitly represent nullable values using an Option. So far in my experiments with Sodium I have ended up having cells containing an option like this: Cell<Option<T>>. This is usually because I don't have a value when I create the Cell so I need to use a None. This imposes a cost down the line though because now every usage of this Cell needs to check if there is a value or not. Typically, these types of Cells are used similarly to a Cell<bool>, as a "gate" for certain Streams where I only want to allow a signal to pass if the Cell has data (or not sometimes).
I think that often rather than having a Cell<bool> to gate a stream, and then another Cell<Option<T>> it would be more convenient to have an operation to split a stream based on a Cell<Option<T>>, basically a s.snapshot(&opt_cell).split_opt() combinator...
Maybe this doesn't need to be explicitly implemented.
In Rust, it's common to explicitly represent nullable values using an
Option
. So far in my experiments with Sodium I have ended up having cells containing an option like this:Cell<Option<T>>
. This is usually because I don't have a value when I create theCell
so I need to use aNone
. This imposes a cost down the line though because now every usage of thisCell
needs to check if there is a value or not. Typically, these types ofCells
are used similarly to aCell<bool>
, as a "gate" for certainStreams
where I only want to allow a signal to pass if theCell
has data (or not sometimes).I think that often rather than having a
Cell<bool>
to gate a stream, and then anotherCell<Option<T>>
it would be more convenient to have an operation to split a stream based on aCell<Option<T>>
, basically as.snapshot(&opt_cell).split_opt()
combinator...Maybe this doesn't need to be explicitly implemented.