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

    C-FeatureA new feature, making something new possibleS-Needs-TriageThis issue needs to be labelled

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions