std: Add Default implementation for vecs

This commit is contained in:
Erick Tryzelaar 2013-09-09 19:32:56 -07:00
parent e6c11313c8
commit 2bd87ad432

View File

@ -104,6 +104,7 @@ use clone::{Clone, DeepClone};
use container::{Container, Mutable};
use cmp::{Eq, TotalOrd, Ordering, Less, Equal, Greater};
use cmp;
use default::Default;
use iter::*;
use libc::c_void;
use num::{Integer, Zero, CheckedAdd, Saturating};
@ -2236,6 +2237,19 @@ impl<A: DeepClone> DeepClone for ~[A] {
}
}
// This works because every lifetime is a sub-lifetime of 'static
impl<'self, A> Default for &'self [A] {
fn default() -> &'self [A] { &'self [] }
}
impl<A> Default for ~[A] {
fn default() -> ~[A] { ~[] }
}
impl<A> Default for @[A] {
fn default() -> @[A] { @[] }
}
// This works because every lifetime is a sub-lifetime of 'static
impl<'self, A> Zero for &'self [A] {
fn zero() -> &'self [A] { &'self [] }