mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 02:57:37 +00:00
std: Add Default implementation for vecs
This commit is contained in:
parent
e6c11313c8
commit
2bd87ad432
@ -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 [] }
|
||||
|
Loading…
Reference in New Issue
Block a user