rust: str: implement `Display` and `Debug` for `BStr`
authorYutaro Ohno <yutaro.ono.418@gmail.com>
Thu, 8 Feb 2024 09:55:36 +0000 (18:55 +0900)
committerMiguel Ojeda <ojeda@kernel.org>
Sun, 25 Feb 2024 18:17:31 +0000 (19:17 +0100)
commit4951ddd51b816b5e4095cd3cd3bd46fb73b96a65
treefc5f089f9456c13e6d30bd46fe0f87d77f499783
parent1b6170ff7a203a5e8354f19b7839fe8b897a9c0d
rust: str: implement `Display` and `Debug` for `BStr`

Currently, `BStr` is just a type alias of `[u8]`, limiting its
representation to a byte list rather than a character list, which is not
ideal for printing and debugging.

Implement `Display` and `Debug` traits for `BStr` to facilitate easier
printing and debugging.

Also, for this purpose, change `BStr` from a type alias of `[u8]` to a
struct wrapper of `[u8]`.

Co-developed-by: Virgile Andreani <armavica@ulminfo.fr>
Signed-off-by: Virgile Andreani <armavica@ulminfo.fr>
Signed-off-by: Yutaro Ohno <yutaro.ono.418@gmail.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Link: https://lore.kernel.org/r/ZcSlGMGP-e9HqybA@ohnotp
[ Formatted code comment. ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
rust/kernel/str.rs