Skip to content

Shared resource extractor (Res) should allow non-optional resources #60

@dfunckt

Description

@dfunckt

Using this example from docs:

fn multiple_resources(conn: Res<MyConnection>, config: Res<MyConfig>) {
    // a reference to the resources configured in the Worker below
    // can be access within the Job handler
}

Accessing conn returns an Option<MyConnection> which forces the user to unsafely unwrap if they know it can't be nil, which is unnecessary, unnatural and tedious, but most importantly fails to capture user intent with types.

If the user configures the system for Res<T>, then they should get T back. If T can indeed be nil, then providing Res<Option<T>> should do the trick.

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