From be4e64cdbbf186b3d39bda2c97d47a0ac5f622a3 Mon Sep 17 00:00:00 2001 From: daxpedda Date: Sat, 7 Sep 2024 17:31:54 +0200 Subject: [PATCH] Update Clippy to v1.81 --- crates/cli/tests/reference/raw.js | 48 +++++++++++++++---------------- examples/todomvc/src/template.rs | 6 +--- 2 files changed, 25 insertions(+), 29 deletions(-) diff --git a/crates/cli/tests/reference/raw.js b/crates/cli/tests/reference/raw.js index 3432d150366..6b831debb89 100644 --- a/crates/cli/tests/reference/raw.js +++ b/crates/cli/tests/reference/raw.js @@ -6,26 +6,6 @@ export function __wbg_set_wasm(val) { } -const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder; - -let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true }); - -cachedTextDecoder.decode(); - -let cachedUint8ArrayMemory0 = null; - -function getUint8ArrayMemory0() { - if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) { - cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer); - } - return cachedUint8ArrayMemory0; -} - -function getStringFromWasm0(ptr, len) { - ptr = ptr >>> 0; - return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len)); -} - const heap = new Array(128).fill(undefined); heap.push(undefined, null, true, false); @@ -45,6 +25,26 @@ function takeObject(idx) { dropObject(idx); return ret; } + +const lTextDecoder = typeof TextDecoder === 'undefined' ? (0, module.require)('util').TextDecoder : TextDecoder; + +let cachedTextDecoder = new lTextDecoder('utf-8', { ignoreBOM: true, fatal: true }); + +cachedTextDecoder.decode(); + +let cachedUint8ArrayMemory0 = null; + +function getUint8ArrayMemory0() { + if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) { + cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer); + } + return cachedUint8ArrayMemory0; +} + +function getStringFromWasm0(ptr, len) { + ptr = ptr >>> 0; + return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len)); +} /** * @param {number} test * @returns {number} @@ -110,11 +110,11 @@ export function __wbg_test2_39fe629b9aa739cf() { return addHeapObject(ret); }; -export function __wbindgen_throw(arg0, arg1) { - throw new Error(getStringFromWasm0(arg0, arg1)); -}; - export function __wbindgen_object_drop_ref(arg0) { takeObject(arg0); }; +export function __wbindgen_throw(arg0, arg1) { + throw new Error(getStringFromWasm0(arg0, arg1)); +}; + diff --git a/examples/todomvc/src/template.rs b/examples/todomvc/src/template.rs index 20b800ce860..a4e9af4bb92 100644 --- a/examples/todomvc/src/template.rs +++ b/examples/todomvc/src/template.rs @@ -46,10 +46,6 @@ impl Template { /// Returns the contents for an "items left" indicator pub fn item_counter(active_todos: usize) -> String { let items_left = ItemsLeftTemplate { active_todos }; - if let Ok(res) = items_left.render() { - res - } else { - String::new() - } + items_left.render().unwrap_or_default() } }