Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

rust: alloc: implement Display for Box

Currently `impl Display` is missing for `Box<T, A>`, as a result,
things like using `Box<..>` directly as an operand in `pr_info!()`
are impossible, which is less ergonomic compared to `Box` in Rust
std.

Therefore add `impl Display` for `Box`.

Acked-by: Danilo Krummrich <dakr@kernel.org>
Suggested-by: Boqun Feng <boqun.feng@gmail.com>
Link: https://github.com/Rust-for-Linux/linux/issues/1126
Signed-off-by: Guangbo Cui <2407018371@qq.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Link: https://lore.kernel.org/r/tencent_2AD25C6A6898D3A598CBA54BB6AF59BB900A@qq.com
[ Reworded title. - Miguel ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>

authored by

Guangbo Cui and committed by
Miguel Ojeda
21e08aa5 2dde1c8b

+10
+10
rust/kernel/alloc/kbox.rs
··· 427 427 } 428 428 } 429 429 430 + impl<T, A> fmt::Display for Box<T, A> 431 + where 432 + T: ?Sized + fmt::Display, 433 + A: Allocator, 434 + { 435 + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { 436 + <T as fmt::Display>::fmt(&**self, f) 437 + } 438 + } 439 + 430 440 impl<T, A> fmt::Debug for Box<T, A> 431 441 where 432 442 T: ?Sized + fmt::Debug,