mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-25 22:22:44 +00:00
remove remaining is_not_empty functions/methods
This commit is contained in:
parent
ec3f6e1932
commit
e4337a9def
@ -70,7 +70,7 @@ fn parse_config(args: ~[~str]) -> config {
|
|||||||
getopts::optopt(~"logfile"),
|
getopts::optopt(~"logfile"),
|
||||||
getopts::optflag(~"jit")];
|
getopts::optflag(~"jit")];
|
||||||
|
|
||||||
assert (vec::is_not_empty(args));
|
assert !args.is_empty();
|
||||||
let args_ = vec::tail(args);
|
let args_ = vec::tail(args);
|
||||||
let matches =
|
let matches =
|
||||||
&match getopts::getopts(args_, opts) {
|
&match getopts::getopts(args_, opts) {
|
||||||
|
@ -208,8 +208,6 @@ impl<T> DList<T> {
|
|||||||
pure fn len(@self) -> uint { self.size }
|
pure fn len(@self) -> uint { self.size }
|
||||||
/// Returns true if the list is empty. O(1).
|
/// Returns true if the list is empty. O(1).
|
||||||
pure fn is_empty(@self) -> bool { self.len() == 0 }
|
pure fn is_empty(@self) -> bool { self.len() == 0 }
|
||||||
/// Returns true if the list is not empty. O(1).
|
|
||||||
pure fn is_not_empty(@self) -> bool { self.len() != 0 }
|
|
||||||
|
|
||||||
/// Add data to the head of the list. O(1).
|
/// Add data to the head of the list. O(1).
|
||||||
fn push_head(@self, data: T) {
|
fn push_head(@self, data: T) {
|
||||||
@ -648,8 +646,6 @@ mod tests {
|
|||||||
let full1 = from_vec(~[1,2,3]);
|
let full1 = from_vec(~[1,2,3]);
|
||||||
assert empty.is_empty();
|
assert empty.is_empty();
|
||||||
assert !full1.is_empty();
|
assert !full1.is_empty();
|
||||||
assert !empty.is_not_empty();
|
|
||||||
assert full1.is_not_empty();
|
|
||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
fn test_dlist_head_tail() {
|
fn test_dlist_head_tail() {
|
||||||
|
@ -1419,9 +1419,6 @@ pub pure fn is_ascii(s: &str) -> bool {
|
|||||||
/// Returns true if the string has length 0
|
/// Returns true if the string has length 0
|
||||||
pub pure fn is_empty(s: &str) -> bool { len(s) == 0u }
|
pub pure fn is_empty(s: &str) -> bool { len(s) == 0u }
|
||||||
|
|
||||||
/// Returns true if the string has length greater than 0
|
|
||||||
pub pure fn is_not_empty(s: &str) -> bool { !is_empty(s) }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the string contains only whitespace
|
* Returns true if the string contains only whitespace
|
||||||
*
|
*
|
||||||
@ -2167,7 +2164,6 @@ pub trait StrSlice {
|
|||||||
pure fn each_chari(it: fn(uint, char) -> bool);
|
pure fn each_chari(it: fn(uint, char) -> bool);
|
||||||
pure fn ends_with(needle: &str) -> bool;
|
pure fn ends_with(needle: &str) -> bool;
|
||||||
pure fn is_empty() -> bool;
|
pure fn is_empty() -> bool;
|
||||||
pure fn is_not_empty() -> bool;
|
|
||||||
pure fn is_whitespace() -> bool;
|
pure fn is_whitespace() -> bool;
|
||||||
pure fn is_alphanumeric() -> bool;
|
pure fn is_alphanumeric() -> bool;
|
||||||
pure fn len() -> uint;
|
pure fn len() -> uint;
|
||||||
@ -2229,9 +2225,6 @@ impl &str: StrSlice {
|
|||||||
/// Returns true if the string has length 0
|
/// Returns true if the string has length 0
|
||||||
#[inline]
|
#[inline]
|
||||||
pure fn is_empty() -> bool { is_empty(self) }
|
pure fn is_empty() -> bool { is_empty(self) }
|
||||||
/// Returns true if the string has length greater than 0
|
|
||||||
#[inline]
|
|
||||||
pure fn is_not_empty() -> bool { is_not_empty(self) }
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the string contains only whitespace
|
* Returns true if the string contains only whitespace
|
||||||
*
|
*
|
||||||
@ -2739,12 +2732,6 @@ mod tests {
|
|||||||
assert (!is_empty(~"a"));
|
assert (!is_empty(~"a"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_is_not_empty() {
|
|
||||||
assert (is_not_empty(~"a"));
|
|
||||||
assert (!is_not_empty(~""));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_replace() {
|
fn test_replace() {
|
||||||
let a = ~"a";
|
let a = ~"a";
|
||||||
|
@ -84,7 +84,7 @@ terminate normally, but instead directly return from a function.
|
|||||||
|
|
||||||
~~~
|
~~~
|
||||||
fn choose_weighted_item(v: &[Item]) -> Item {
|
fn choose_weighted_item(v: &[Item]) -> Item {
|
||||||
assert v.is_not_empty();
|
assert !v.is_empty();
|
||||||
let mut so_far = 0u;
|
let mut so_far = 0u;
|
||||||
for v.each |item| {
|
for v.each |item| {
|
||||||
so_far += item.weight;
|
so_far += item.weight;
|
||||||
|
@ -49,11 +49,6 @@ pub pure fn is_empty<T>(v: &[const T]) -> bool {
|
|||||||
as_const_buf(v, |_p, len| len == 0u)
|
as_const_buf(v, |_p, len| len == 0u)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns true if a vector contains some elements
|
|
||||||
pub pure fn is_not_empty<T>(v: &[const T]) -> bool {
|
|
||||||
as_const_buf(v, |_p, len| len > 0u)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns true if two vectors have the same length
|
/// Returns true if two vectors have the same length
|
||||||
pub pure fn same_length<T, U>(xs: &[const T], ys: &[const U]) -> bool {
|
pub pure fn same_length<T, U>(xs: &[const T], ys: &[const U]) -> bool {
|
||||||
len(xs) == len(ys)
|
len(xs) == len(ys)
|
||||||
@ -2515,12 +2510,6 @@ mod tests {
|
|||||||
assert (!is_empty(~[0]));
|
assert (!is_empty(~[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_is_not_empty() {
|
|
||||||
assert (is_not_empty(~[0]));
|
|
||||||
assert (!is_not_empty::<int>(~[]));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_len_divzero() {
|
fn test_len_divzero() {
|
||||||
type Z = [i8 * 0];
|
type Z = [i8 * 0];
|
||||||
|
@ -167,7 +167,7 @@ fn get_relative_to(abs1: &Path, abs2: &Path) -> Path {
|
|||||||
|
|
||||||
path.push_all(vec::view(split2, start_idx, len2 - 1));
|
path.push_all(vec::view(split2, start_idx, len2 - 1));
|
||||||
|
|
||||||
if vec::is_not_empty(path) {
|
if !path.is_empty() {
|
||||||
return Path("").push_many(path);
|
return Path("").push_many(path);
|
||||||
} else {
|
} else {
|
||||||
return Path(".");
|
return Path(".");
|
||||||
|
@ -1018,8 +1018,8 @@ fn synthesize_crate_attrs(ecx: @encode_ctxt, crate: &crate) -> ~[attribute] {
|
|||||||
fn synthesize_link_attr(ecx: @encode_ctxt, +items: ~[@meta_item]) ->
|
fn synthesize_link_attr(ecx: @encode_ctxt, +items: ~[@meta_item]) ->
|
||||||
attribute {
|
attribute {
|
||||||
|
|
||||||
assert ecx.link_meta.name.is_not_empty();
|
assert !ecx.link_meta.name.is_empty();
|
||||||
assert ecx.link_meta.vers.is_not_empty();
|
assert !ecx.link_meta.vers.is_empty();
|
||||||
|
|
||||||
let name_item =
|
let name_item =
|
||||||
attr::mk_name_value_item_str(~"name",
|
attr::mk_name_value_item_str(~"name",
|
||||||
|
@ -179,7 +179,7 @@ fn crate_matches(crate_data: @~[u8], +metas: ~[@ast::meta_item],
|
|||||||
hash: ~str) -> bool {
|
hash: ~str) -> bool {
|
||||||
let attrs = decoder::get_crate_attributes(crate_data);
|
let attrs = decoder::get_crate_attributes(crate_data);
|
||||||
let linkage_metas = attr::find_linkage_metas(attrs);
|
let linkage_metas = attr::find_linkage_metas(attrs);
|
||||||
if hash.is_not_empty() {
|
if !hash.is_empty() {
|
||||||
let chash = decoder::get_crate_hash(crate_data);
|
let chash = decoder::get_crate_hash(crate_data);
|
||||||
if chash != hash { return false; }
|
if chash != hash { return false; }
|
||||||
}
|
}
|
||||||
|
@ -820,7 +820,7 @@ fn check_item_path_statement(cx: ty::ctxt, it: @ast::item) {
|
|||||||
fn check_item_non_camel_case_types(cx: ty::ctxt, it: @ast::item) {
|
fn check_item_non_camel_case_types(cx: ty::ctxt, it: @ast::item) {
|
||||||
fn is_camel_case(cx: ty::ctxt, ident: ast::ident) -> bool {
|
fn is_camel_case(cx: ty::ctxt, ident: ast::ident) -> bool {
|
||||||
let ident = cx.sess.str_of(ident);
|
let ident = cx.sess.str_of(ident);
|
||||||
assert ident.is_not_empty();
|
assert !ident.is_empty();
|
||||||
let ident = ident_without_trailing_underscores(ident);
|
let ident = ident_without_trailing_underscores(ident);
|
||||||
let ident = ident_without_leading_underscores(ident);
|
let ident = ident_without_leading_underscores(ident);
|
||||||
char::is_uppercase(str::char_at(ident, 0)) &&
|
char::is_uppercase(str::char_at(ident, 0)) &&
|
||||||
|
@ -127,7 +127,7 @@ pub fn parse_hidden(+attrs: ~[ast::attribute]) -> bool {
|
|||||||
match attr::get_meta_item_list(*meta) {
|
match attr::get_meta_item_list(*meta) {
|
||||||
Some(metas) => {
|
Some(metas) => {
|
||||||
let hiddens = attr::find_meta_items_by_name(metas, ~"hidden");
|
let hiddens = attr::find_meta_items_by_name(metas, ~"hidden");
|
||||||
vec::is_not_empty(hiddens)
|
!hiddens.is_empty()
|
||||||
}
|
}
|
||||||
None => false
|
None => false
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,7 @@ fn parse_desc(desc: ~str) -> Option<~str> {
|
|||||||
|
|
||||||
fn first_sentence(s: ~str) -> Option<~str> {
|
fn first_sentence(s: ~str) -> Option<~str> {
|
||||||
let paras = paragraphs(s);
|
let paras = paragraphs(s);
|
||||||
if vec::is_not_empty(paras) {
|
if !paras.is_empty() {
|
||||||
let first_para = vec::head(paras);
|
let first_para = vec::head(paras);
|
||||||
Some(str::replace(first_sentence_(first_para), ~"\n", ~" "))
|
Some(str::replace(first_sentence_(first_para), ~"\n", ~" "))
|
||||||
} else {
|
} else {
|
||||||
@ -193,7 +193,7 @@ fn paragraphs(s: ~str) -> ~[~str] {
|
|||||||
whitespace_lines += 1;
|
whitespace_lines += 1;
|
||||||
} else {
|
} else {
|
||||||
if whitespace_lines > 0 {
|
if whitespace_lines > 0 {
|
||||||
if str::is_not_empty(accum) {
|
if !accum.is_empty() {
|
||||||
res += ~[accum];
|
res += ~[accum];
|
||||||
accum = ~"";
|
accum = ~"";
|
||||||
}
|
}
|
||||||
@ -211,7 +211,7 @@ fn paragraphs(s: ~str) -> ~[~str] {
|
|||||||
res
|
res
|
||||||
};
|
};
|
||||||
|
|
||||||
if str::is_not_empty(accum) {
|
if !accum.is_empty() {
|
||||||
paras + ~[accum]
|
paras + ~[accum]
|
||||||
} else {
|
} else {
|
||||||
paras
|
paras
|
||||||
|
@ -78,7 +78,7 @@ fn unindent(s: ~str) -> ~str {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if vec::is_not_empty(lines) {
|
if !lines.is_empty() {
|
||||||
let unindented = ~[str::trim(vec::head(lines))]
|
let unindented = ~[str::trim(vec::head(lines))]
|
||||||
+ do par::map(vec::tail(lines)) |line| {
|
+ do par::map(vec::tail(lines)) |line| {
|
||||||
if str::is_whitespace(*line) {
|
if str::is_whitespace(*line) {
|
||||||
|
@ -83,11 +83,6 @@ pub pure fn is_empty<T: Copy>(ls: @List<T>) -> bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns true if the list is not empty
|
|
||||||
pub pure fn is_not_empty<T: Copy>(ls: @List<T>) -> bool {
|
|
||||||
return !is_empty(ls);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns the length of a list
|
/// Returns the length of a list
|
||||||
pub pure fn len<T>(ls: @List<T>) -> uint {
|
pub pure fn len<T>(ls: @List<T>) -> uint {
|
||||||
let mut count = 0u;
|
let mut count = 0u;
|
||||||
@ -177,10 +172,6 @@ mod tests {
|
|||||||
assert is_empty(empty);
|
assert is_empty(empty);
|
||||||
assert !is_empty(full1);
|
assert !is_empty(full1);
|
||||||
assert !is_empty(full2);
|
assert !is_empty(full2);
|
||||||
|
|
||||||
assert !is_not_empty(empty);
|
|
||||||
assert is_not_empty(full1);
|
|
||||||
assert is_not_empty(full2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -245,7 +245,7 @@ fn contains_name(metas: &[@ast::meta_item], name: &str) -> bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn attrs_contains_name(attrs: &[ast::attribute], name: &str) -> bool {
|
fn attrs_contains_name(attrs: &[ast::attribute], name: &str) -> bool {
|
||||||
vec::is_not_empty(find_attrs_by_name(attrs, name))
|
!find_attrs_by_name(attrs, name).is_empty()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn first_attr_value_str_by_name(attrs: ~[ast::attribute], name: ~str)
|
fn first_attr_value_str_by_name(attrs: ~[ast::attribute], name: ~str)
|
||||||
|
@ -192,7 +192,7 @@ fn diagnosticcolor(lvl: level) -> u8 {
|
|||||||
fn print_diagnostic(topic: ~str, lvl: level, msg: &str) {
|
fn print_diagnostic(topic: ~str, lvl: level, msg: &str) {
|
||||||
let use_color = term::color_supported() &&
|
let use_color = term::color_supported() &&
|
||||||
io::stderr().get_type() == io::Screen;
|
io::stderr().get_type() == io::Screen;
|
||||||
if str::is_not_empty(topic) {
|
if !topic.is_empty() {
|
||||||
io::stderr().write_str(fmt!("%s ", topic));
|
io::stderr().write_str(fmt!("%s ", topic));
|
||||||
}
|
}
|
||||||
if use_color {
|
if use_color {
|
||||||
|
@ -2237,7 +2237,7 @@ impl Parser {
|
|||||||
|
|
||||||
fn check_expected_item(p: Parser, current_attrs: ~[attribute]) {
|
fn check_expected_item(p: Parser, current_attrs: ~[attribute]) {
|
||||||
// If we have attributes then we should have an item
|
// If we have attributes then we should have an item
|
||||||
if vec::is_not_empty(current_attrs) {
|
if !current_attrs.is_empty() {
|
||||||
p.fatal(~"expected item after attrs");
|
p.fatal(~"expected item after attrs");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ pure fn pure_length<T: Copy>(ls: @List<T>) -> uint { pure_length_go(ls, 0u) }
|
|||||||
pure fn nonempty_list<T: Copy>(ls: @List<T>) -> bool { pure_length(ls) > 0u }
|
pure fn nonempty_list<T: Copy>(ls: @List<T>) -> bool { pure_length(ls) > 0u }
|
||||||
|
|
||||||
fn safe_head<T: Copy>(ls: @List<T>) -> T {
|
fn safe_head<T: Copy>(ls: @List<T>) -> T {
|
||||||
assert is_not_empty(ls);
|
assert !is_empty(ls);
|
||||||
return head(ls);
|
return head(ls);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
// In this case, the code should compile and should
|
// In this case, the code should compile and should
|
||||||
// succeed at runtime
|
// succeed at runtime
|
||||||
use vec::{head, is_not_empty, last, same_length, zip};
|
use vec::{head, last, same_length, zip};
|
||||||
|
|
||||||
fn enum_chars(start: u8, end: u8) -> ~[char] {
|
fn enum_chars(start: u8, end: u8) -> ~[char] {
|
||||||
assert start < end;
|
assert start < end;
|
||||||
|
Loading…
Reference in New Issue
Block a user