Advanced Hands-on Rust: get_handle is unwieldy (page 118)

The function body as it’s presented is quite unwieldy. It was probably a good opportunity to point out to the audience that ? can also be used to shortcirquit an Option as well, not just a Result:

impl AssetStore {
  pub fn get_handle<T>(&self, index: &str, assets: &LoadedAssets) 
  -> Option<Handle<T>>
  where T: Asset,
  {
    if let Some(handle_untyped) = self.asset_index.get(index) {
      if let Some(handle) = assets.get(handle_untyped) {
        return Some(handle.handle.clone().typed::<T>());
      }
      None
    } else {
      None
    }
  }
}

into

impl AssetStore {
    pub fn get_handle<T: Asset>(&self, index: &str, assets: &LoadedAssets) -> Option<Handle<T>> {
        let handle_untyped = self.asset_index.get(index)?;
        let handle = assets.get(handle_untyped)?;

        Some(handle.handle.clone().typed::<T>())
    }
}