We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Rc<T>::default
1 parent 2e8dd5b commit fe5101dCopy full SHA for fe5101d
alloc/src/rc.rs
@@ -2312,7 +2312,16 @@ impl<T: Default> Default for Rc<T> {
2312
/// ```
2313
#[inline]
2314
fn default() -> Rc<T> {
2315
- Rc::new(Default::default())
+ unsafe {
2316
+ Self::from_inner(
2317
+ Box::leak(Box::write(Box::new_uninit(), RcInner {
2318
+ strong: Cell::new(1),
2319
+ weak: Cell::new(1),
2320
+ value: T::default(),
2321
+ }))
2322
+ .into(),
2323
+ )
2324
+ }
2325
}
2326
2327
0 commit comments