RS.CLIPPY.BOX_DEFAULT

Using Box::new(T::default()) instead of Box::default()

This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: box_default. Copyright ©2025 The Rust Team. All rights reserved.

What it does

checks for Box::new(Default::default()), which can be written as Box::default().

Why is this bad?

Box::default() is equivalent and more concise.

Example

let x: Box<String> = Box::new(Default::default());

Use instead:

let x: Box<String> = Box::default();