Skip to content

child_signal_vec unwraps on a None value when the SignalVec is empty #3

@broomlytinum

Description

@broomlytinum

I've been working with this version of Pinwheel due to an issue with nested block_ons in child_signal_vec when the child nodes have dynamic components themselves. I'm assuming the usage of now_or_never is to avoid this scenario (or a similar one?).

However, I believe there is an issue with unwrapping the result of now_or_never, as the future will be pending if the SignalVec is empty.

This smaller example demonstrates the panic:

use futures::{future::FutureExt, stream::StreamExt};
use futures_signals::signal_vec::{SignalVecExt, MutableVec};

fn main() {
    let vec = MutableVec::<bool>::new();

    vec.signal_vec()
        .to_stream()
        .next()
        .now_or_never()
        .unwrap();
}

I don't believe there's any need to unwrap it, and any alternative I can think of without unwrapping has the same end result. Though, I'm uneasy with leaving an Option unwrapped like that, so I haven't simply submitted a pull request.

If disallowing zero children in child_signal_vec was an intentional design decision, you may disregard this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions