refactor: rework uri_encode to limit allocation

add add some related tests.

catched from clippy lint `format_collect`
message: use of `format!` to build up a string from an iterator
  --> src/api/common/encoding.rs:12:17
   |
12 |                   let value = format!("{}", c)
   |  _____________________________^
13 | |                     .bytes()
14 | |                     .map(|b| format!("%{:02X}", b))
15 | |                     .collect::<String>();
   | |________________________________________^
   |
help: call `fold` instead
  --> src/api/common/encoding.rs:14:7
   |
14 |                     .map(|b| format!("%{:02X}", b))
   |                      ^^^
help: ... and use the `write!` macro here
  --> src/api/common/encoding.rs:14:15
   |
14 |                     .map(|b| format!("%{:02X}", b))
   |                              ^^^^^^^^^^^^^^^^^^^^^
   = note: this can be written more efficiently by appending to a `String` directly
   = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#format_collect
This commit is contained in:
Gwen Lg
2026-02-02 18:37:07 +01:00
committed by Alex
parent 83f8bdbacd
commit 9b3e4716bf
2 changed files with 93 additions and 6 deletions
+1
View File
@@ -183,6 +183,7 @@ strip = "debuginfo"
[workspace.lints.clippy]
# pedantic lints configuration
doc_markdown = "warn"
format_collect = "warn"
manual_midpoint = "warn"
semicolon_if_nothing_returned = "warn"
unnecessary_semicolon = "warn"