Skip to content

Commit e4337a9

Browse files
committed
remove remaining is_not_empty functions/methods
1 parent ec3f6e1 commit e4337a9

File tree

18 files changed

+17
-54
lines changed

18 files changed

+17
-54
lines changed

src/compiletest/compiletest.rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ fn parse_config(args: ~[~str]) -> config {
7070
getopts::optopt(~"logfile"),
7171
getopts::optflag(~"jit")];
7272

73-
assert (vec::is_not_empty(args));
73+
assert !args.is_empty();
7474
let args_ = vec::tail(args);
7575
let matches =
7676
&match getopts::getopts(args_, opts) {

src/libcore/dlist.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,6 @@ impl<T> DList<T> {
208208
pure fn len(@self) -> uint { self.size }
209209
/// Returns true if the list is empty. O(1).
210210
pure fn is_empty(@self) -> bool { self.len() == 0 }
211-
/// Returns true if the list is not empty. O(1).
212-
pure fn is_not_empty(@self) -> bool { self.len() != 0 }
213211
214212
/// Add data to the head of the list. O(1).
215213
fn push_head(@self, data: T) {
@@ -648,8 +646,6 @@ mod tests {
648646
let full1 = from_vec(~[1,2,3]);
649647
assert empty.is_empty();
650648
assert !full1.is_empty();
651-
assert !empty.is_not_empty();
652-
assert full1.is_not_empty();
653649
}
654650
#[test]
655651
fn test_dlist_head_tail() {

src/libcore/str.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,9 +1419,6 @@ pub pure fn is_ascii(s: &str) -> bool {
14191419
/// Returns true if the string has length 0
14201420
pub pure fn is_empty(s: &str) -> bool { len(s) == 0u }
14211421

1422-
/// Returns true if the string has length greater than 0
1423-
pub pure fn is_not_empty(s: &str) -> bool { !is_empty(s) }
1424-
14251422
/**
14261423
* Returns true if the string contains only whitespace
14271424
*
@@ -2167,7 +2164,6 @@ pub trait StrSlice {
21672164
pure fn each_chari(it: fn(uint, char) -> bool);
21682165
pure fn ends_with(needle: &str) -> bool;
21692166
pure fn is_empty() -> bool;
2170-
pure fn is_not_empty() -> bool;
21712167
pure fn is_whitespace() -> bool;
21722168
pure fn is_alphanumeric() -> bool;
21732169
pure fn len() -> uint;
@@ -2229,9 +2225,6 @@ impl &str: StrSlice {
22292225
/// Returns true if the string has length 0
22302226
#[inline]
22312227
pure fn is_empty() -> bool { is_empty(self) }
2232-
/// Returns true if the string has length greater than 0
2233-
#[inline]
2234-
pure fn is_not_empty() -> bool { is_not_empty(self) }
22352228
/**
22362229
* Returns true if the string contains only whitespace
22372230
*
@@ -2739,12 +2732,6 @@ mod tests {
27392732
assert (!is_empty(~"a"));
27402733
}
27412734

2742-
#[test]
2743-
fn test_is_not_empty() {
2744-
assert (is_not_empty(~"a"));
2745-
assert (!is_not_empty(~""));
2746-
}
2747-
27482735
#[test]
27492736
fn test_replace() {
27502737
let a = ~"a";

src/libcore/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ terminate normally, but instead directly return from a function.
8484
8585
~~~
8686
fn choose_weighted_item(v: &[Item]) -> Item {
87-
assert v.is_not_empty();
87+
assert !v.is_empty();
8888
let mut so_far = 0u;
8989
for v.each |item| {
9090
so_far += item.weight;

src/libcore/vec.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,6 @@ pub pure fn is_empty<T>(v: &[const T]) -> bool {
4949
as_const_buf(v, |_p, len| len == 0u)
5050
}
5151

52-
/// Returns true if a vector contains some elements
53-
pub pure fn is_not_empty<T>(v: &[const T]) -> bool {
54-
as_const_buf(v, |_p, len| len > 0u)
55-
}
56-
5752
/// Returns true if two vectors have the same length
5853
pub pure fn same_length<T, U>(xs: &[const T], ys: &[const U]) -> bool {
5954
len(xs) == len(ys)
@@ -2515,12 +2510,6 @@ mod tests {
25152510
assert (!is_empty(~[0]));
25162511
}
25172512

2518-
#[test]
2519-
fn test_is_not_empty() {
2520-
assert (is_not_empty(~[0]));
2521-
assert (!is_not_empty::<int>(~[]));
2522-
}
2523-
25242513
#[test]
25252514
fn test_len_divzero() {
25262515
type Z = [i8 * 0];

src/librustc/back/rpath.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ fn get_relative_to(abs1: &Path, abs2: &Path) -> Path {
167167

168168
path.push_all(vec::view(split2, start_idx, len2 - 1));
169169

170-
if vec::is_not_empty(path) {
170+
if !path.is_empty() {
171171
return Path("").push_many(path);
172172
} else {
173173
return Path(".");

src/librustc/metadata/encoder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,8 +1018,8 @@ fn synthesize_crate_attrs(ecx: @encode_ctxt, crate: &crate) -> ~[attribute] {
10181018
fn synthesize_link_attr(ecx: @encode_ctxt, +items: ~[@meta_item]) ->
10191019
attribute {
10201020

1021-
assert ecx.link_meta.name.is_not_empty();
1022-
assert ecx.link_meta.vers.is_not_empty();
1021+
assert !ecx.link_meta.name.is_empty();
1022+
assert !ecx.link_meta.vers.is_empty();
10231023

10241024
let name_item =
10251025
attr::mk_name_value_item_str(~"name",

src/librustc/metadata/loader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ fn crate_matches(crate_data: @~[u8], +metas: ~[@ast::meta_item],
179179
hash: ~str) -> bool {
180180
let attrs = decoder::get_crate_attributes(crate_data);
181181
let linkage_metas = attr::find_linkage_metas(attrs);
182-
if hash.is_not_empty() {
182+
if !hash.is_empty() {
183183
let chash = decoder::get_crate_hash(crate_data);
184184
if chash != hash { return false; }
185185
}

src/librustc/middle/lint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,7 @@ fn check_item_path_statement(cx: ty::ctxt, it: @ast::item) {
820820
fn check_item_non_camel_case_types(cx: ty::ctxt, it: @ast::item) {
821821
fn is_camel_case(cx: ty::ctxt, ident: ast::ident) -> bool {
822822
let ident = cx.sess.str_of(ident);
823-
assert ident.is_not_empty();
823+
assert !ident.is_empty();
824824
let ident = ident_without_trailing_underscores(ident);
825825
let ident = ident_without_leading_underscores(ident);
826826
char::is_uppercase(str::char_at(ident, 0)) &&

src/librustdoc/attr_parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ pub fn parse_hidden(+attrs: ~[ast::attribute]) -> bool {
127127
match attr::get_meta_item_list(*meta) {
128128
Some(metas) => {
129129
let hiddens = attr::find_meta_items_by_name(metas, ~"hidden");
130-
vec::is_not_empty(hiddens)
130+
!hiddens.is_empty()
131131
}
132132
None => false
133133
}

src/librustdoc/desc_to_brief_pass.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ fn parse_desc(desc: ~str) -> Option<~str> {
143143

144144
fn first_sentence(s: ~str) -> Option<~str> {
145145
let paras = paragraphs(s);
146-
if vec::is_not_empty(paras) {
146+
if !paras.is_empty() {
147147
let first_para = vec::head(paras);
148148
Some(str::replace(first_sentence_(first_para), ~"\n", ~" "))
149149
} else {
@@ -193,7 +193,7 @@ fn paragraphs(s: ~str) -> ~[~str] {
193193
whitespace_lines += 1;
194194
} else {
195195
if whitespace_lines > 0 {
196-
if str::is_not_empty(accum) {
196+
if !accum.is_empty() {
197197
res += ~[accum];
198198
accum = ~"";
199199
}
@@ -211,7 +211,7 @@ fn paragraphs(s: ~str) -> ~[~str] {
211211
res
212212
};
213213

214-
if str::is_not_empty(accum) {
214+
if !accum.is_empty() {
215215
paras + ~[accum]
216216
} else {
217217
paras

src/librustdoc/unindent_pass.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ fn unindent(s: ~str) -> ~str {
7878
}
7979
};
8080

81-
if vec::is_not_empty(lines) {
81+
if !lines.is_empty() {
8282
let unindented = ~[str::trim(vec::head(lines))]
8383
+ do par::map(vec::tail(lines)) |line| {
8484
if str::is_whitespace(*line) {

src/libstd/list.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,6 @@ pub pure fn is_empty<T: Copy>(ls: @List<T>) -> bool {
8383
}
8484
}
8585

86-
/// Returns true if the list is not empty
87-
pub pure fn is_not_empty<T: Copy>(ls: @List<T>) -> bool {
88-
return !is_empty(ls);
89-
}
90-
9186
/// Returns the length of a list
9287
pub pure fn len<T>(ls: @List<T>) -> uint {
9388
let mut count = 0u;
@@ -177,10 +172,6 @@ mod tests {
177172
assert is_empty(empty);
178173
assert !is_empty(full1);
179174
assert !is_empty(full2);
180-
181-
assert !is_not_empty(empty);
182-
assert is_not_empty(full1);
183-
assert is_not_empty(full2);
184175
}
185176

186177
#[test]

src/libsyntax/attr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ fn contains_name(metas: &[@ast::meta_item], name: &str) -> bool {
245245
}
246246

247247
fn attrs_contains_name(attrs: &[ast::attribute], name: &str) -> bool {
248-
vec::is_not_empty(find_attrs_by_name(attrs, name))
248+
!find_attrs_by_name(attrs, name).is_empty()
249249
}
250250

251251
fn first_attr_value_str_by_name(attrs: ~[ast::attribute], name: ~str)

src/libsyntax/diagnostic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ fn diagnosticcolor(lvl: level) -> u8 {
192192
fn print_diagnostic(topic: ~str, lvl: level, msg: &str) {
193193
let use_color = term::color_supported() &&
194194
io::stderr().get_type() == io::Screen;
195-
if str::is_not_empty(topic) {
195+
if !topic.is_empty() {
196196
io::stderr().write_str(fmt!("%s ", topic));
197197
}
198198
if use_color {

src/libsyntax/parse/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2237,7 +2237,7 @@ impl Parser {
22372237
22382238
fn check_expected_item(p: Parser, current_attrs: ~[attribute]) {
22392239
// If we have attributes then we should have an item
2240-
if vec::is_not_empty(current_attrs) {
2240+
if !current_attrs.is_empty() {
22412241
p.fatal(~"expected item after attrs");
22422242
}
22432243
}

src/test/run-pass/non-boolean-pure-fns.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pure fn pure_length<T: Copy>(ls: @List<T>) -> uint { pure_length_go(ls, 0u) }
2323
pure fn nonempty_list<T: Copy>(ls: @List<T>) -> bool { pure_length(ls) > 0u }
2424

2525
fn safe_head<T: Copy>(ls: @List<T>) -> T {
26-
assert is_not_empty(ls);
26+
assert !is_empty(ls);
2727
return head(ls);
2828
}
2929

src/test/run-pass/zip-same-length.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
// In this case, the code should compile and should
1212
// succeed at runtime
13-
use vec::{head, is_not_empty, last, same_length, zip};
13+
use vec::{head, last, same_length, zip};
1414

1515
fn enum_chars(start: u8, end: u8) -> ~[char] {
1616
assert start < end;

0 commit comments

Comments
 (0)