On Sun Jun 15, 2025 at 10:32 PM JST, Miguel Ojeda wrote: > On Thu, Jun 12, 2025 at 4:02 PM Alexandre Courbot <acour...@nvidia.com> wrote: >> >> + /// >> assert_eq!(PowerOfTwo::<u32>::try_new(16).unwrap().value(), 16); > > By the way, we are trying to write examples close to normal kernel > code as possible, so could you please use `?` here instead of > `unwrap()`? > > It is not a big deal, when within `assert`s, but there is value in not > showing any `unwrap()`s, and to spot easily places where we actually > do `unwrap()`.
The fact that `try_new` returns an `Option` makes it a bit difficult to do nicely - one would have to add a verbose `ok_or` to turn it into a `Result`. But that doesn't matter as this test can be (better) written as follows: assert_eq!(PowerOfTwo::<u32>::try_new(16), Some(PowerOfTwo::<u32>::new(16))); And all is well. > Also, please use intra-doc links wherever they may work, e.g. I think > [`PowerOfTwo`] and [`None`] will work. Added the links where relevant, sorry for the omission!