Add From<String> for AssetPath<'a> (#6337)
# Objective Fixes #6291 ## Solution Implement `From<String>` for `AssetPath<'a>`
This commit is contained in:
parent
0f3f628c48
commit
c226fee707
@ -187,3 +187,15 @@ impl<'a> From<PathBuf> for AssetPath<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> From<String> for AssetPath<'a> {
|
||||||
|
fn from(asset_path: String) -> Self {
|
||||||
|
let mut parts = asset_path.splitn(2, '#');
|
||||||
|
let path = PathBuf::from(parts.next().expect("Path must be set."));
|
||||||
|
let label = parts.next().map(String::from);
|
||||||
|
AssetPath {
|
||||||
|
path: Cow::Owned(path),
|
||||||
|
label: label.map(Cow::Owned),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user