Re: [PATCH v2 2/5] rust: maple_tree: add MapleTree
From: Miguel Ojeda
Date: Fri Aug 22 2025 - 07:26:53 EST
On Fri, Aug 22, 2025 at 1:05 PM Danilo Krummrich <dakr@xxxxxxxxxx> wrote:
>
> We should probably check if we can get a clippy warning in place for this.
There is https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_used,
which covers all cases.
> we could also write
>
> assert!(tree
> .insert(100, the_answer, GFP_KERNEL)
> .is_err_and(|e| e.cause == InsertErrorKind::Occupied));
If we want to use the Clippy lint, i.e. go hard on avoiding all kinds
of `unwrap()`s, then that is fine.
But I wouldn't do it just for the sake of avoiding a few
`unwrap_err()`s within `assert!`s -- I don't think there is going to
be a problem of having a lot of people concluding it is OK to panic
the kernel in general just because they see an `unwrap_err()` within
an `assert!` -- the `assert!` itself could be also understood as
panicking, after all, and we really don't want to ban `assert!`s on
examples.
Now, if we do get something else out of it, like enforcing no
`unwrap()`s (still bypassable with `allow` etc. if needed) and thus
removing a class of errors, then that sounds worthier to me.
Thanks!
Cheers,
Miguel