Skip to content

Commit

Permalink
Don't .unwrap() in AssetPath::try_parse (bevyengine#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 Ray Redondo committed Jan 9, 2024
1 parent 811f22a commit 81bce55
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 81bce55

Please sign in to comment.