Rust

Rust

Made by DeepSource

Found usage of Box::new(T::default()) RS-P1008

Performance
Minor

Box::new(T::default()) is overly verbose, involving two function calls instead of one. It can be better written as Box::<T>::default().

Bad practice

fn foo() {
    let x: Box<String> = Box::new(Default::default());
    let y = Box::new(i32::default());
}

Recommended

fn foo() {
    let x: Box<String> = Box::default();
    let y = Box::<i32>::default();
}