Skip to content

Commit

Permalink
Don't .unwrap() in AssetPath::try_parse (#10452)
Browse files Browse the repository at this point in the history
# 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.
  • Loading branch information
SludgePhD authored and cart committed Nov 30, 2023
1 parent 4667d80 commit 26dfe42
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion crates/bevy_asset/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ impl<'a> AssetPath<'a> {
///
/// 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> {
let (source, path, label) = Self::parse_internal(asset_path).unwrap();
let (source, path, label) = Self::parse_internal(asset_path)?;
Ok(Self {
source: match source {
Some(source) => AssetSourceId::Name(CowArc::Borrowed(source)),
Expand Down

0 comments on commit 26dfe42

Please sign in to comment.