Skip to content

Into<AssetId<T>> is a massive footgun. #12600

@mintlu8

Description

@mintlu8

How can Bevy's documentation be improved?

This conversion is used a lot in bevy_asset and can be mimicked by users. Unfortunately this can be used drop a strong handle, thus the associated asset. For example

fn asset_command(mut commands: Commands, asset: impl Into<AssetId<T>>) {
    commands.add(MyCommand(asset.into()))
}

This may drop the asset before the command is applied, leading to hard to find bugs.

I think either document this or provide a better trait.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-AssetsLoad files from disk to use for things like images, models, and soundsC-BugAn unexpected or incorrect behaviorD-TrivialNice and easy! A great choice to get started with BevyM-Migration-GuideA breaking change to Bevy's public API that needs to be noted in a migration guide

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions