mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
improvement: load_cloned returns a result
This commit is contained in:
parent
0a1e12c9ad
commit
f1b728b89b
@ -85,9 +85,9 @@ pub fn load<A: Asset + 'static>(specifier: &str) -> Result<Arc<A>, Error> {
|
||||
}
|
||||
|
||||
/// Function used to load assets from the filesystem or the cache and return a clone.
|
||||
pub fn load_cloned<A: Asset + Clone + 'static>(specifier: &str) -> Option<A> {
|
||||
let asset: Option<Arc<A>> = load(specifier).ok();
|
||||
asset.map(|asset| (*asset).clone())
|
||||
pub fn load_cloned<A: Asset + Clone + 'static>(specifier: &str) -> Result<A, Error> {
|
||||
let asset = load(specifier);
|
||||
asset.map(|asset: Arc<A>| (*asset).clone())
|
||||
}
|
||||
|
||||
/// Function used to load essential assets from the filesystem or the cache. It will panic if the asset is not found.
|
||||
|
@ -205,7 +205,7 @@ impl Server {
|
||||
server_settings: &ServerSettings,
|
||||
) {
|
||||
// Give no item when an invalid specifier is given
|
||||
let main = main.and_then(|specifier| assets::load_cloned(&specifier));
|
||||
let main = main.and_then(|specifier| assets::load_cloned(&specifier).ok());
|
||||
|
||||
let spawn_point = state.ecs().read_resource::<SpawnPoint>().0;
|
||||
|
||||
|
@ -98,7 +98,7 @@ impl PlayState for CharSelectionState {
|
||||
main: self
|
||||
.char_selection_ui
|
||||
.character_tool
|
||||
.and_then(|specifier| assets::load_cloned(&specifier)),
|
||||
.and_then(|specifier| assets::load_cloned(&specifier).ok()),
|
||||
alt: None,
|
||||
},
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user