Skip to content

Accept &AssetPath instead of &str in AssetPath::resolve #22239

@Shatur

Description

@Shatur

What problem does this solve or what need does it fill?

AssetPath::resolve and AssetPath::resolve_embed accept &str and parse it internaly. But if you already have AssetPath, it's wasteful to call .to_string and let resolve parse it again:

if let Some(label) = path.strip_prefix('#') {
// It's a label only
Ok(self.clone_owned().with_label(label.to_owned()))
} else {
let (source, rpath, rlabel) = AssetPath::parse_internal(path)?;

What solution would you like?

Accept &AssetPath instead of &str in AssetPath::resolve looks like a better API to me.

What alternative(s) have you considered?

Add _str suffix to the current methods and and new methods that accept &AcceptPath.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-AssetsLoad files from disk to use for things like images, models, and soundsC-UsabilityA targeted quality-of-life change that makes Bevy easier to useD-StraightforwardSimple bug fixes and API improvements, docs, test and examplesS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!X-UncontroversialThis work is generally agreed upon

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions