Skip to content

Commit 1ea9991

Browse files
committed
alloc: impl Default for Rc
1 parent 2317840 commit 1ea9991

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/liballoc/rc.rs

+8
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ use core::mem::transmute;
2727
use core::cell::Cell;
2828
use core::clone::Clone;
2929
use core::cmp::{PartialEq, PartialOrd, Eq, Ord, Ordering};
30+
use core::default::Default;
3031
use core::kinds::marker;
3132
use core::ops::{Deref, Drop};
3233
use core::option::{Option, Some, None};
@@ -152,6 +153,13 @@ impl<T> Clone for Rc<T> {
152153
}
153154
}
154155

156+
impl<T: Default> Default for Rc<T> {
157+
#[inline]
158+
fn default() -> Rc<T> {
159+
Rc::new(Default::default())
160+
}
161+
}
162+
155163
impl<T: PartialEq> PartialEq for Rc<T> {
156164
#[inline(always)]
157165
fn eq(&self, other: &Rc<T>) -> bool { **self == **other }

0 commit comments

Comments
 (0)