From fb021d7ceff3f8b1d7cdb0c2bdd75ea07c0428d2 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Wed, 15 Mar 2023 17:46:36 -0400 Subject: refactor: remove usages of `map_or` / `map_or_else` (#18212) These methods are confusing because the arguments are backwards. I feel like they should have never been added to `Option` and that clippy should suggest rewriting to `map(...).unwrap_or(...)`/`map(...).unwrap_or_else(|| ...)` https://github.com/rust-lang/rfcs/issues/1025 --- ext/webgpu/lib.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'ext/webgpu/lib.rs') diff --git a/ext/webgpu/lib.rs b/ext/webgpu/lib.rs index d399125c7..0cdcf6327 100644 --- a/ext/webgpu/lib.rs +++ b/ext/webgpu/lib.rs @@ -252,10 +252,9 @@ pub async fn op_webgpu_request_adapter( ) -> Result { let mut state = state.borrow_mut(); check_unstable(&state, "navigator.gpu.requestAdapter"); - let backends = std::env::var("DENO_WEBGPU_BACKEND").map_or_else( - |_| wgpu_types::Backends::all(), - |s| wgpu_core::instance::parse_backends_from_comma_list(&s), - ); + let backends = std::env::var("DENO_WEBGPU_BACKEND") + .map(|s| wgpu_core::instance::parse_backends_from_comma_list(&s)) + .unwrap_or_else(|_| wgpu_types::Backends::all()); let instance = if let Some(instance) = state.try_borrow::() { instance } else { -- cgit v1.2.3