Skip to content

Commit 43aba85

Browse files
committed
std: Remove Zero impl from vec
Vecs are not numeric types, so it doesn't make sense for them to implement Zero.
1 parent a0e123e commit 43aba85

File tree

2 files changed

+7
-25
lines changed

2 files changed

+7
-25
lines changed

src/libstd/vec.rs

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ use cmp;
107107
use default::Default;
108108
use iter::*;
109109
use libc::c_void;
110-
use num::{Integer, Zero, CheckedAdd, Saturating};
110+
use num::{Integer, CheckedAdd, Saturating};
111111
use option::{None, Option, Some};
112112
use ptr::to_unsafe_ptr;
113113
use ptr;
@@ -2250,22 +2250,6 @@ impl<A> Default for @[A] {
22502250
fn default() -> @[A] { @[] }
22512251
}
22522252

2253-
// This works because every lifetime is a sub-lifetime of 'static
2254-
impl<'self, A> Zero for &'self [A] {
2255-
fn zero() -> &'self [A] { &'self [] }
2256-
fn is_zero(&self) -> bool { self.is_empty() }
2257-
}
2258-
2259-
impl<A> Zero for ~[A] {
2260-
fn zero() -> ~[A] { ~[] }
2261-
fn is_zero(&self) -> bool { self.len() == 0 }
2262-
}
2263-
2264-
impl<A> Zero for @[A] {
2265-
fn zero() -> @[A] { @[] }
2266-
fn is_zero(&self) -> bool { self.len() == 0 }
2267-
}
2268-
22692253
macro_rules! iterator {
22702254
/* FIXME: #4375 Cannot attach documentation/attributes to a macro generated struct.
22712255
(struct $name:ident -> $ptr:ty, $elem:ty) => {
@@ -3602,13 +3586,12 @@ mod tests {
36023586
}
36033587

36043588
#[test]
3605-
fn test_vec_zero() {
3606-
use num::Zero;
3589+
fn test_vec_default() {
3590+
use default::Default;
36073591
macro_rules! t (
36083592
($ty:ty) => {{
3609-
let v: $ty = Zero::zero();
3593+
let v: $ty = Default::default();
36103594
assert!(v.is_empty());
3611-
assert!(v.is_zero());
36123595
}}
36133596
);
36143597

src/test/run-pass/deriving-zero.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,9 @@ struct Lots {
2929
e: char,
3030
f: float,
3131
g: (f32, char),
32-
h: ~[util::NonCopyable],
33-
i: @mut (int, int),
34-
j: bool,
35-
k: (),
32+
h: @mut (int, int),
33+
i: bool,
34+
j: (),
3635
}
3736

3837
fn main() {

0 commit comments

Comments
 (0)