summaryrefslogtreecommitdiff
path: root/ext/webgpu/lib.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2023-03-15 17:46:36 -0400
committerGitHub <noreply@github.com>2023-03-15 17:46:36 -0400
commitfb021d7ceff3f8b1d7cdb0c2bdd75ea07c0428d2 (patch)
tree09cb2bf87bba760b1abf706e0b8faedc9c368bbc /ext/webgpu/lib.rs
parentca51f4f6c058d16ac438ad75ac92e8954895f5aa (diff)
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<T>` and that clippy should suggest rewriting to `map(...).unwrap_or(...)`/`map(...).unwrap_or_else(|| ...)` https://github.com/rust-lang/rfcs/issues/1025
Diffstat (limited to 'ext/webgpu/lib.rs')
-rw-r--r--ext/webgpu/lib.rs7
1 files changed, 3 insertions, 4 deletions
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<GpuAdapterDeviceOrErr, AnyError> {
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>() {
instance
} else {