@@ -390,7 +390,12 @@ impl<T, A: Allocator> Box<T, A> {
390390 // #[unstable(feature = "new_uninit", issue = "63291")]
391391 pub fn new_uninit_in ( alloc : A ) -> Box < mem:: MaybeUninit < T > , A > {
392392 let layout = Layout :: new :: < mem:: MaybeUninit < T > > ( ) ;
393- Box :: try_new_uninit_in ( alloc) . unwrap_or_else ( |_| handle_alloc_error ( layout) )
393+ // NOTE: Prefer match over unwrap_or_else since closure sometimes not inlineable.
394+ // That would make code size bigger.
395+ match Box :: try_new_uninit_in ( alloc) {
396+ Ok ( m) => m,
397+ Err ( _) => handle_alloc_error ( layout) ,
398+ }
394399 }
395400
396401 /// Constructs a new box with uninitialized contents in the provided allocator,
@@ -447,7 +452,12 @@ impl<T, A: Allocator> Box<T, A> {
447452 // #[unstable(feature = "new_uninit", issue = "63291")]
448453 pub fn new_zeroed_in ( alloc : A ) -> Box < mem:: MaybeUninit < T > , A > {
449454 let layout = Layout :: new :: < mem:: MaybeUninit < T > > ( ) ;
450- Box :: try_new_zeroed_in ( alloc) . unwrap_or_else ( |_| handle_alloc_error ( layout) )
455+ // NOTE: Prefer match over unwrap_or_else since closure sometimes not inlineable.
456+ // That would make code size bigger.
457+ match Box :: try_new_zeroed_in ( alloc) {
458+ Ok ( m) => m,
459+ Err ( _) => handle_alloc_error ( layout) ,
460+ }
451461 }
452462
453463 /// Constructs a new `Box` with uninitialized contents, with the memory
0 commit comments