Don't .unwrap() in AssetPath::try_parse (#10452)

# Objective

- The docs on `AssetPath::try_parse` say that it will return an error
when the string is malformed, but it actually just `.unwrap()`s the
result.

## Solution

- Use `?` instead of unwrapping the result.
This commit is contained in:
Sludge 2023-11-09 19:07:48 +01:00 committed by Carter Anderson
parent 4667d80243
commit 26dfe42623

View file

@ -115,7 +115,7 @@ impl<'a> AssetPath<'a> {
/// ///
/// This will return a [`ParseAssetPathError`] if `asset_path` is in an invalid format. /// This will return a [`ParseAssetPathError`] if `asset_path` is in an invalid format.
pub fn try_parse(asset_path: &'a str) -> Result<AssetPath<'a>, ParseAssetPathError> { pub fn try_parse(asset_path: &'a str) -> Result<AssetPath<'a>, ParseAssetPathError> {
let (source, path, label) = Self::parse_internal(asset_path).unwrap(); let (source, path, label) = Self::parse_internal(asset_path)?;
Ok(Self { Ok(Self {
source: match source { source: match source {
Some(source) => AssetSourceId::Name(CowArc::Borrowed(source)), Some(source) => AssetSourceId::Name(CowArc::Borrowed(source)),