auto merge of #6487 : recrack/rust/vec_len, r=thestinger
Rename vec::len(var) to var.len() ``` libcore, libfuzzer, librustc, librustdoc, libstd, libsyntax test/auxiliary test/bench test/run-pass ```
This commit is contained in:
commit
4e82610099
@ -264,7 +264,7 @@ fn run_debuginfo_test(config: &config, props: &TestProps, testfile: &Path) {
|
||||
fatal(~"gdb failed to execute");
|
||||
}
|
||||
|
||||
let num_check_lines = vec::len(check_lines);
|
||||
let num_check_lines = check_lines.len();
|
||||
if num_check_lines > 0 {
|
||||
// check if each line in props.check_lines appears in the
|
||||
// output (in order)
|
||||
@ -303,7 +303,7 @@ fn check_error_patterns(props: &TestProps,
|
||||
if str::contains(line, *next_err_pat) {
|
||||
debug!("found error pattern %s", *next_err_pat);
|
||||
next_err_idx += 1u;
|
||||
if next_err_idx == vec::len(props.error_patterns) {
|
||||
if next_err_idx == props.error_patterns.len() {
|
||||
debug!("found all error patterns");
|
||||
done = true;
|
||||
break;
|
||||
@ -315,8 +315,8 @@ fn check_error_patterns(props: &TestProps,
|
||||
|
||||
let missing_patterns =
|
||||
vec::slice(props.error_patterns, next_err_idx,
|
||||
vec::len(props.error_patterns));
|
||||
if vec::len(missing_patterns) == 1u {
|
||||
props.error_patterns.len());
|
||||
if missing_patterns.len() == 1u {
|
||||
fatal_ProcRes(fmt!("error pattern '%s' not found!",
|
||||
missing_patterns[0]), ProcRes);
|
||||
} else {
|
||||
@ -333,7 +333,7 @@ fn check_expected_errors(expected_errors: ~[errors::ExpectedError],
|
||||
|
||||
// true if we found the error in question
|
||||
let mut found_flags = vec::from_elem(
|
||||
vec::len(expected_errors), false);
|
||||
expected_errors.len(), false);
|
||||
|
||||
if ProcRes.status == 0 {
|
||||
fatal(~"process did not return an error status");
|
||||
@ -377,7 +377,7 @@ fn check_expected_errors(expected_errors: ~[errors::ExpectedError],
|
||||
}
|
||||
}
|
||||
|
||||
for uint::range(0u, vec::len(found_flags)) |i| {
|
||||
for uint::range(0u, found_flags.len()) |i| {
|
||||
if !found_flags[i] {
|
||||
let ee = &expected_errors[i];
|
||||
fatal_ProcRes(fmt!("expected %s on line %u not found: %s",
|
||||
|
@ -201,14 +201,14 @@ fn test_lefts() {
|
||||
fn test_lefts_none() {
|
||||
let input: ~[Either<int, int>] = ~[Right(10), Right(10)];
|
||||
let result = lefts(input);
|
||||
assert_eq!(vec::len(result), 0u);
|
||||
assert_eq!(result.len(), 0u);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_lefts_empty() {
|
||||
let input: ~[Either<int, int>] = ~[];
|
||||
let result = lefts(input);
|
||||
assert_eq!(vec::len(result), 0u);
|
||||
assert_eq!(result.len(), 0u);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -222,14 +222,14 @@ fn test_rights() {
|
||||
fn test_rights_none() {
|
||||
let input: ~[Either<int, int>] = ~[Left(10), Left(10)];
|
||||
let result = rights(input);
|
||||
assert_eq!(vec::len(result), 0u);
|
||||
assert_eq!(result.len(), 0u);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_rights_empty() {
|
||||
let input: ~[Either<int, int>] = ~[];
|
||||
let result = rights(input);
|
||||
assert_eq!(vec::len(result), 0u);
|
||||
assert_eq!(result.len(), 0u);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -247,22 +247,22 @@ fn test_partition() {
|
||||
fn test_partition_no_lefts() {
|
||||
let input: ~[Either<int, int>] = ~[Right(10), Right(11)];
|
||||
let (lefts, rights) = partition(input);
|
||||
assert_eq!(vec::len(lefts), 0u);
|
||||
assert_eq!(vec::len(rights), 2u);
|
||||
assert_eq!(lefts.len(), 0u);
|
||||
assert_eq!(rights.len(), 2u);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_partition_no_rights() {
|
||||
let input: ~[Either<int, int>] = ~[Left(10), Left(11)];
|
||||
let (lefts, rights) = partition(input);
|
||||
assert_eq!(vec::len(lefts), 2u);
|
||||
assert_eq!(vec::len(rights), 0u);
|
||||
assert_eq!(lefts.len(), 2u);
|
||||
assert_eq!(rights.len(), 0u);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_partition_empty() {
|
||||
let input: ~[Either<int, int>] = ~[];
|
||||
let (lefts, rights) = partition(input);
|
||||
assert_eq!(vec::len(lefts), 0u);
|
||||
assert_eq!(vec::len(rights), 0u);
|
||||
assert_eq!(lefts.len(), 0u);
|
||||
assert_eq!(rights.len(), 0u);
|
||||
}
|
||||
|
@ -673,10 +673,10 @@ impl<T:Reader> ReaderUtil for T {
|
||||
|
||||
fn read_char(&self) -> char {
|
||||
let c = self.read_chars(1);
|
||||
if vec::len(c) == 0 {
|
||||
if c.len() == 0 {
|
||||
return -1 as char; // FIXME will this stay valid? // #2004
|
||||
}
|
||||
assert!((vec::len(c) == 1));
|
||||
assert!(c.len() == 1);
|
||||
return c[0];
|
||||
}
|
||||
|
||||
@ -1802,7 +1802,7 @@ mod tests {
|
||||
fn test_readchars_empty() {
|
||||
do io::with_str_reader(~"") |inp| {
|
||||
let res : ~[char] = inp.read_chars(128);
|
||||
assert!((vec::len(res) == 0));
|
||||
assert!(res.len() == 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1841,10 +1841,10 @@ mod tests {
|
||||
fn check_read_ln(len : uint, s: &str, ivals: &[int]) {
|
||||
do io::with_str_reader(s) |inp| {
|
||||
let res : ~[char] = inp.read_chars(len);
|
||||
if (len <= vec::len(ivals)) {
|
||||
assert!((vec::len(res) == len));
|
||||
if len <= ivals.len() {
|
||||
assert!(res.len() == len);
|
||||
}
|
||||
assert!(vec::slice(ivals, 0u, vec::len(res)) ==
|
||||
assert!(vec::slice(ivals, 0u, res.len()) ==
|
||||
vec::map(res, |x| *x as int));
|
||||
}
|
||||
}
|
||||
|
@ -410,7 +410,7 @@ pub fn self_exe_path() -> Option<Path> {
|
||||
KERN_PROC as c_int,
|
||||
KERN_PROC_PATHNAME as c_int, -1 as c_int];
|
||||
let mut sz = sz;
|
||||
sysctl(vec::raw::to_ptr(mib), vec::len(mib) as ::libc::c_uint,
|
||||
sysctl(vec::raw::to_ptr(mib), mib.len() as ::libc::c_uint,
|
||||
buf as *mut c_void, &mut sz, ptr::null(),
|
||||
0u as size_t) == (0 as c_int)
|
||||
}
|
||||
@ -1490,7 +1490,7 @@ mod tests {
|
||||
#[ignore]
|
||||
fn test_env_getenv() {
|
||||
let e = env();
|
||||
assert!(vec::len(e) > 0u);
|
||||
assert!(e.len() > 0u);
|
||||
for e.each |p| {
|
||||
let (n, v) = copy *p;
|
||||
debug!(copy n);
|
||||
@ -1581,7 +1581,7 @@ mod tests {
|
||||
fn list_dir() {
|
||||
let dirs = os::list_dir(&Path("."));
|
||||
// Just assuming that we've got some contents in the current directory
|
||||
assert!((vec::len(dirs) > 0u));
|
||||
assert!(dirs.len() > 0u);
|
||||
|
||||
for dirs.each |dir| {
|
||||
debug!(copy *dir);
|
||||
|
@ -441,7 +441,7 @@ pub mod ptr_tests {
|
||||
let arr_ptr = &arr[0];
|
||||
let mut ctr = 0;
|
||||
let mut iteration_count = 0;
|
||||
array_each_with_len(arr_ptr, vec::len(arr),
|
||||
array_each_with_len(arr_ptr, arr.len(),
|
||||
|e| {
|
||||
let actual = str::raw::from_c_str(e);
|
||||
let expected = copy expected_arr[ctr];
|
||||
|
@ -221,7 +221,7 @@ pub unsafe fn accept(server: *c_void, client: *c_void) -> c_int {
|
||||
|
||||
pub unsafe fn write<T>(req: *uv_write_t, stream: *T, buf_in: &[uv_buf_t], cb: *u8) -> c_int {
|
||||
let buf_ptr = vec::raw::to_ptr(buf_in);
|
||||
let buf_cnt = vec::len(buf_in) as i32;
|
||||
let buf_cnt = buf_in.len() as i32;
|
||||
return rust_uv_write(req as *c_void, stream as *c_void, buf_ptr, buf_cnt, cb);
|
||||
}
|
||||
pub unsafe fn read_start(stream: *uv_stream_t, on_alloc: *u8, on_read: *u8) -> c_int {
|
||||
|
@ -2059,7 +2059,7 @@ pub fn is_utf8(v: &const [u8]) -> bool {
|
||||
|
||||
/// Determines if a vector of `u16` contains valid UTF-16
|
||||
pub fn is_utf16(v: &[u16]) -> bool {
|
||||
let len = vec::len(v);
|
||||
let len = v.len();
|
||||
let mut i = 0u;
|
||||
while (i < len) {
|
||||
let u = v[i];
|
||||
@ -2103,7 +2103,7 @@ pub fn to_utf16(s: &str) -> ~[u16] {
|
||||
}
|
||||
|
||||
pub fn utf16_chars(v: &[u16], f: &fn(char)) {
|
||||
let len = vec::len(v);
|
||||
let len = v.len();
|
||||
let mut i = 0u;
|
||||
while (i < len && v[i] != 0u16) {
|
||||
let u = v[i];
|
||||
@ -2128,7 +2128,7 @@ pub fn utf16_chars(v: &[u16], f: &fn(char)) {
|
||||
|
||||
pub fn from_utf16(v: &[u16]) -> ~str {
|
||||
let mut buf = ~"";
|
||||
reserve(&mut buf, vec::len(v));
|
||||
reserve(&mut buf, v.len());
|
||||
utf16_chars(v, |ch| push_char(&mut buf, ch));
|
||||
buf
|
||||
}
|
||||
@ -2398,7 +2398,7 @@ static tag_six_b: uint = 252u;
|
||||
* # Example
|
||||
*
|
||||
* ~~~
|
||||
* let i = str::as_bytes("Hello World") { |bytes| vec::len(bytes) };
|
||||
* let i = str::as_bytes("Hello World") { |bytes| bytes.len() };
|
||||
* ~~~
|
||||
*/
|
||||
#[inline]
|
||||
|
@ -15,8 +15,8 @@ fn vec_equal<T>(v: ~[T],
|
||||
u: ~[T],
|
||||
element_equality_test: @fn(&&T, &&T) -> bool) ->
|
||||
bool {
|
||||
let Lv = vec::len(v);
|
||||
if Lv != vec::len(u) { return false; }
|
||||
let Lv = v.len();
|
||||
if Lv != u.len() { return false; }
|
||||
let i = 0u;
|
||||
while i < Lv {
|
||||
if !element_equality_test(v[i], u[i]) { return false; }
|
||||
|
@ -19,7 +19,7 @@ fn under(r : rand::rng, n : uint) -> uint {
|
||||
|
||||
// random choice from a vec
|
||||
fn choice<T:copy>(r : rand::rng, v : ~[const T]) -> T {
|
||||
assert!(vec::len(v) != 0u); v[under(r, vec::len(v))]
|
||||
assert!(v.len() != 0u); v[under(r, v.len())]
|
||||
}
|
||||
|
||||
// k in n chance of being true
|
||||
|
@ -18,7 +18,7 @@ fn under(r : rand::rng, n : uint) -> uint {
|
||||
|
||||
// random choice from a vec
|
||||
fn choice<T:copy>(r : rand::rng, v : ~[T]) -> T {
|
||||
assert!(vec::len(v) != 0u); v[under(r, vec::len(v))]
|
||||
assert!(v.len() != 0u); v[under(r, v.len())]
|
||||
}
|
||||
|
||||
// 1 in n chance of being true
|
||||
@ -26,7 +26,7 @@ fn unlikely(r : rand::rng, n : uint) -> bool { under(r, n) == 0u }
|
||||
|
||||
// shuffle a vec in place
|
||||
fn shuffle<T>(r : rand::rng, &v : ~[T]) {
|
||||
let i = vec::len(v);
|
||||
let i = v.len();
|
||||
while i >= 2u {
|
||||
// Loop invariant: elements with index >= i have been locked in place.
|
||||
i -= 1u;
|
||||
@ -49,7 +49,7 @@ fn shuffled<T:copy>(r : rand::rng, v : ~[T]) -> ~[T] {
|
||||
// * weighted_vec is O(total weight) space
|
||||
type weighted<T> = { weight: uint, item: T };
|
||||
fn weighted_choice<T:copy>(r : rand::rng, v : ~[weighted<T>]) -> T {
|
||||
assert!(vec::len(v) != 0u);
|
||||
assert!(v.len() != 0u);
|
||||
let total = 0u;
|
||||
for {weight: weight, item: _} in v {
|
||||
total += weight;
|
||||
|
@ -137,8 +137,8 @@ pub fn get_relative_to(abs1: &Path, abs2: &Path) -> Path {
|
||||
abs1.to_str(), abs2.to_str());
|
||||
let split1: &[~str] = abs1.components;
|
||||
let split2: &[~str] = abs2.components;
|
||||
let len1 = vec::len(split1);
|
||||
let len2 = vec::len(split2);
|
||||
let len1 = split1.len();
|
||||
let len2 = split2.len();
|
||||
assert!(len1 > 0);
|
||||
assert!(len2 > 0);
|
||||
|
||||
|
@ -905,7 +905,6 @@ mod test {
|
||||
use driver::driver::{build_configuration, build_session};
|
||||
use driver::driver::{build_session_options, optgroups, str_input};
|
||||
|
||||
use core::vec;
|
||||
use std::getopts::groups::getopts;
|
||||
use std::getopts;
|
||||
use syntax::attr;
|
||||
@ -942,6 +941,6 @@ mod test {
|
||||
let sess = build_session(sessopts, diagnostic::emit);
|
||||
let cfg = build_configuration(sess, @~"whatever", &str_input(~""));
|
||||
let test_items = attr::find_meta_items_by_name(cfg, ~"test");
|
||||
assert!((vec::len(test_items) == 1u));
|
||||
assert!(test_items.len() == 1u);
|
||||
}
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ fn is_bench_fn(i: @ast::item) -> bool {
|
||||
fn has_test_signature(i: @ast::item) -> bool {
|
||||
match i.node {
|
||||
ast::item_fn(ref decl, _, _, ref generics, _) => {
|
||||
let input_cnt = vec::len(decl.inputs);
|
||||
let input_cnt = decl.inputs.len();
|
||||
let no_output = match decl.output.node {
|
||||
ast::ty_nil => true,
|
||||
_ => false
|
||||
|
@ -1063,7 +1063,7 @@ fn get_attributes(md: ebml::Doc) -> ~[ast::attribute] {
|
||||
let meta_items = get_meta_items(attr_doc);
|
||||
// Currently it's only possible to have a single meta item on
|
||||
// an attribute
|
||||
assert!((vec::len(meta_items) == 1u));
|
||||
assert!(meta_items.len() == 1u);
|
||||
let meta_item = meta_items[0];
|
||||
attrs.push(
|
||||
codemap::spanned {
|
||||
|
@ -171,7 +171,7 @@ pub fn metadata_matches(extern_metas: &[@ast::meta_item],
|
||||
local_metas: &[@ast::meta_item]) -> bool {
|
||||
|
||||
debug!("matching %u metadata requirements against %u items",
|
||||
vec::len(local_metas), vec::len(extern_metas));
|
||||
local_metas.len(), extern_metas.len());
|
||||
|
||||
for local_metas.each |needed| {
|
||||
if !attr::contains(extern_metas, *needed) {
|
||||
|
@ -507,7 +507,7 @@ fn parse_sig(st: @mut PState, conv: conv_did) -> ty::FnSig {
|
||||
// Rust metadata parsing
|
||||
pub fn parse_def_id(buf: &[u8]) -> ast::def_id {
|
||||
let mut colon_idx = 0u;
|
||||
let len = vec::len(buf);
|
||||
let len = buf.len();
|
||||
while colon_idx < len && buf[colon_idx] != ':' as u8 { colon_idx += 1u; }
|
||||
if colon_idx == len {
|
||||
error!("didn't find ':' when parsing def id");
|
||||
|
@ -360,7 +360,7 @@ fn is_nullary_variant(cx: Context, ex: @expr) -> bool {
|
||||
expr_path(_) => {
|
||||
match cx.tcx.def_map.get_copy(&ex.id) {
|
||||
def_variant(edid, vdid) => {
|
||||
vec::len(ty::enum_variant_with_id(cx.tcx, edid, vdid).args) == 0u
|
||||
vec::len(ty::enum_variant_with_id(cx.tcx, edid, vdid).args) == 0u
|
||||
}
|
||||
_ => false
|
||||
}
|
||||
|
@ -283,8 +283,8 @@ pub impl RegionMaps {
|
||||
|
||||
let a_ancestors = ancestors_of(self, scope_a);
|
||||
let b_ancestors = ancestors_of(self, scope_b);
|
||||
let mut a_index = vec::len(a_ancestors) - 1u;
|
||||
let mut b_index = vec::len(b_ancestors) - 1u;
|
||||
let mut a_index = a_ancestors.len() - 1u;
|
||||
let mut b_index = b_ancestors.len() - 1u;
|
||||
|
||||
// Here, ~[ab]_ancestors is a vector going from narrow to broad.
|
||||
// The end of each vector will be the item where the scope is
|
||||
|
@ -4706,7 +4706,7 @@ pub impl Resolver {
|
||||
}
|
||||
}
|
||||
|
||||
if vec::len(values) > 0 &&
|
||||
if values.len() > 0 &&
|
||||
values[smallest] != uint::max_value &&
|
||||
values[smallest] < str::len(name) + 2 &&
|
||||
values[smallest] <= max_distance &&
|
||||
|
@ -4720,7 +4720,7 @@ pub impl Resolver {
|
||||
}
|
||||
}
|
||||
|
||||
if vec::len(values) > 0 &&
|
||||
if values.len() > 0 &&
|
||||
values[smallest] != uint::max_value &&
|
||||
values[smallest] < str::len(name) + 2 &&
|
||||
values[smallest] <= max_distance &&
|
||||
|
@ -65,7 +65,7 @@ pub impl FnType {
|
||||
|
||||
let mut llargvals = ~[];
|
||||
let mut i = 0u;
|
||||
let n = vec::len(arg_tys);
|
||||
let n = arg_tys.len();
|
||||
|
||||
if self.sret {
|
||||
let llretptr = GEPi(bcx, llargbundle, [0u, n]);
|
||||
@ -113,7 +113,7 @@ pub impl FnType {
|
||||
if self.sret || !ret_def {
|
||||
return;
|
||||
}
|
||||
let n = vec::len(arg_tys);
|
||||
let n = arg_tys.len();
|
||||
// R** llretptr = &args->r;
|
||||
let llretptr = GEPi(bcx, llargbundle, [0u, n]);
|
||||
// R* llretloc = *llretptr; /* (args->r) */
|
||||
@ -149,7 +149,7 @@ pub impl FnType {
|
||||
};
|
||||
|
||||
let mut i = 0u;
|
||||
let n = vec::len(atys);
|
||||
let n = atys.len();
|
||||
while i < n {
|
||||
let mut argval = get_param(llwrapfn, i + j);
|
||||
if attrs[i].is_some() {
|
||||
|
@ -50,7 +50,7 @@ fn is_sse(c: x86_64_reg_class) -> bool {
|
||||
}
|
||||
|
||||
fn is_ymm(cls: &[x86_64_reg_class]) -> bool {
|
||||
let len = vec::len(cls);
|
||||
let len = cls.len();
|
||||
return (len > 2u &&
|
||||
is_sse(cls[0]) &&
|
||||
cls[1] == sseup_class &&
|
||||
@ -223,8 +223,8 @@ fn classify_ty(ty: TypeRef) -> ~[x86_64_reg_class] {
|
||||
unsafe {
|
||||
let mut i = 0u;
|
||||
let llty = llvm::LLVMGetTypeKind(ty) as int;
|
||||
let e = vec::len(cls);
|
||||
if vec::len(cls) > 2u &&
|
||||
let e = cls.len();
|
||||
if cls.len() > 2u &&
|
||||
(llty == 10 /* struct */ ||
|
||||
llty == 11 /* array */) {
|
||||
if is_sse(cls[i]) {
|
||||
@ -295,7 +295,7 @@ fn llreg_ty(cls: &[x86_64_reg_class]) -> TypeRef {
|
||||
unsafe {
|
||||
let mut tys = ~[];
|
||||
let mut i = 0u;
|
||||
let e = vec::len(cls);
|
||||
let e = cls.len();
|
||||
while i < e {
|
||||
match cls[i] {
|
||||
integer_class => {
|
||||
|
@ -509,7 +509,7 @@ pub fn trans_foreign_mod(ccx: @CrateContext,
|
||||
llargbundle: ValueRef) {
|
||||
let _icx = bcx.insn_ctxt("foreign::wrap::build_args");
|
||||
let ccx = bcx.ccx();
|
||||
let n = vec::len(tys.llsig.llarg_tys);
|
||||
let n = tys.llsig.llarg_tys.len();
|
||||
let implicit_args = first_real_arg; // return + env
|
||||
for uint::range(0, n) |i| {
|
||||
let mut llargval = get_param(llwrapfn, i + implicit_args);
|
||||
|
@ -93,7 +93,7 @@ pub impl Reflector {
|
||||
let mth_ty =
|
||||
ty::mk_bare_fn(tcx, copy self.visitor_methods[mth_idx].fty);
|
||||
let v = self.visitor_val;
|
||||
debug!("passing %u args:", vec::len(args));
|
||||
debug!("passing %u args:", args.len());
|
||||
let bcx = self.bcx;
|
||||
for args.eachi |i, a| {
|
||||
debug!("arg %u: %s", i, val_str(bcx.ccx().tn, *a));
|
||||
@ -224,7 +224,7 @@ pub impl Reflector {
|
||||
let retval = if ty::type_is_bot(fty.sig.output) {0u} else {1u};
|
||||
let extra = ~[self.c_uint(pureval),
|
||||
self.c_uint(sigilval),
|
||||
self.c_uint(vec::len(fty.sig.inputs)),
|
||||
self.c_uint(fty.sig.inputs.len()),
|
||||
self.c_uint(retval)];
|
||||
self.visit(~"enter_fn", copy extra); // XXX: Bad copy.
|
||||
self.visit_sig(retval, &fty.sig);
|
||||
@ -239,7 +239,7 @@ pub impl Reflector {
|
||||
let retval = if ty::type_is_bot(fty.sig.output) {0u} else {1u};
|
||||
let extra = ~[self.c_uint(pureval),
|
||||
self.c_uint(sigilval),
|
||||
self.c_uint(vec::len(fty.sig.inputs)),
|
||||
self.c_uint(fty.sig.inputs.len()),
|
||||
self.c_uint(retval)];
|
||||
self.visit(~"enter_fn", copy extra); // XXX: Bad copy.
|
||||
self.visit_sig(retval, &fty.sig);
|
||||
@ -304,13 +304,13 @@ pub impl Reflector {
|
||||
llfdecl
|
||||
};
|
||||
|
||||
let enum_args = ~[self.c_uint(vec::len(variants)), make_get_disr()]
|
||||
let enum_args = ~[self.c_uint(variants.len()), make_get_disr()]
|
||||
+ self.c_size_and_align(t);
|
||||
do self.bracketed(~"enum", enum_args) |this| {
|
||||
for variants.eachi |i, v| {
|
||||
let variant_args = ~[this.c_uint(i),
|
||||
this.c_int(v.disr_val),
|
||||
this.c_uint(vec::len(v.args)),
|
||||
this.c_uint(v.args.len()),
|
||||
this.c_slice(ccx.sess.str_of(v.name))];
|
||||
do this.bracketed(~"enum_variant", variant_args) |this| {
|
||||
for v.args.eachi |j, a| {
|
||||
|
@ -18,7 +18,6 @@ use middle::trans::common::*;
|
||||
use middle::trans;
|
||||
|
||||
use core::str;
|
||||
use core::vec;
|
||||
|
||||
pub struct Ctxt {
|
||||
next_tag_id: u16,
|
||||
@ -71,6 +70,6 @@ pub fn add_u16(dest: &mut ~[u8], val: u16) {
|
||||
}
|
||||
|
||||
pub fn add_substr(dest: &mut ~[u8], src: ~[u8]) {
|
||||
add_u16(&mut *dest, vec::len(src) as u16);
|
||||
add_u16(&mut *dest, src.len() as u16);
|
||||
*dest += src;
|
||||
}
|
||||
|
@ -2634,7 +2634,7 @@ pub fn deref_sty(cx: ctxt, sty: &sty, explicit: bool) -> Option<mt> {
|
||||
|
||||
ty_enum(did, ref substs) => {
|
||||
let variants = enum_variants(cx, did);
|
||||
if vec::len(*variants) == 1u && vec::len(variants[0].args) == 1u {
|
||||
if (*variants).len() == 1u && variants[0].args.len() == 1u {
|
||||
let v_t = subst(cx, substs, variants[0].args[0]);
|
||||
Some(mt {ty: v_t, mutbl: ast::m_imm})
|
||||
} else {
|
||||
|
@ -3276,7 +3276,7 @@ pub fn instantiate_path(fcx: @mut FnCtxt,
|
||||
debug!(">>> instantiate_path");
|
||||
|
||||
let ty_param_count = tpt.generics.type_param_defs.len();
|
||||
let ty_substs_len = vec::len(pth.types);
|
||||
let ty_substs_len = pth.types.len();
|
||||
|
||||
debug!("ty_param_count=%? ty_substs_len=%?",
|
||||
ty_param_count,
|
||||
|
@ -499,15 +499,15 @@ pub fn compare_impl_method(tcx: ty::ctxt,
|
||||
return;
|
||||
}
|
||||
|
||||
if vec::len(impl_m.fty.sig.inputs) != vec::len(trait_m.fty.sig.inputs) {
|
||||
if impl_m.fty.sig.inputs.len() != trait_m.fty.sig.inputs.len() {
|
||||
tcx.sess.span_err(
|
||||
cm.span,
|
||||
fmt!("method `%s` has %u parameter%s \
|
||||
but the trait has %u",
|
||||
*tcx.sess.str_of(trait_m.ident),
|
||||
vec::len(impl_m.fty.sig.inputs),
|
||||
if vec::len(impl_m.fty.sig.inputs) == 1 { "" } else { "s" },
|
||||
vec::len(trait_m.fty.sig.inputs)));
|
||||
impl_m.fty.sig.inputs.len(),
|
||||
if impl_m.fty.sig.inputs.len() == 1 { "" } else { "s" },
|
||||
trait_m.fty.sig.inputs.len()));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -310,7 +310,7 @@ fn check_main_fn_ty(ccx: @mut CrateCtxt,
|
||||
_ => ()
|
||||
}
|
||||
let mut ok = ty::type_is_nil(fn_ty.sig.output);
|
||||
let num_args = vec::len(fn_ty.sig.inputs);
|
||||
let num_args = fn_ty.sig.inputs.len();
|
||||
ok &= num_args == 0u;
|
||||
if !ok {
|
||||
tcx.sess.span_err(
|
||||
|
@ -470,7 +470,7 @@ pub fn parameterized(cx: ctxt,
|
||||
}
|
||||
};
|
||||
|
||||
if vec::len(tps) > 0u {
|
||||
if tps.len() > 0u {
|
||||
let strs = vec::map(tps, |t| ty_to_str(cx, *t));
|
||||
fmt!("%s%s<%s>", base, r_str, str::connect(strs, ","))
|
||||
} else {
|
||||
|
@ -405,7 +405,7 @@ mod test {
|
||||
#[test]
|
||||
fn should_not_add_impl_trait_types_if_none() {
|
||||
let doc = mk_doc(~"impl int { fn a() { } }");
|
||||
assert!(vec::len(doc.cratemod().impls()[0].trait_types) == 0);
|
||||
assert!(doc.cratemod().impls()[0].trait_types.len() == 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -628,7 +628,6 @@ pub mod writer {
|
||||
|
||||
use core::io;
|
||||
use core::str;
|
||||
use core::vec;
|
||||
|
||||
// ebml writing
|
||||
pub struct Encoder {
|
||||
@ -707,7 +706,7 @@ pub mod writer {
|
||||
|
||||
fn wr_tagged_bytes(&mut self, tag_id: uint, b: &[u8]) {
|
||||
write_vuint(self.writer, tag_id);
|
||||
write_vuint(self.writer, vec::len(b));
|
||||
write_vuint(self.writer, b.len());
|
||||
self.writer.write(b);
|
||||
}
|
||||
|
||||
@ -760,7 +759,7 @@ pub mod writer {
|
||||
}
|
||||
|
||||
fn wr_bytes(&mut self, b: &[u8]) {
|
||||
debug!("Write %u bytes", vec::len(b));
|
||||
debug!("Write %u bytes", b.len());
|
||||
self.writer.write(b);
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ pub fn md4(msg: &[u8]) -> Quad {
|
||||
// subtle: if orig_len is merely uint, then the code below
|
||||
// which performs shifts by 32 bits or more has undefined
|
||||
// results.
|
||||
let orig_len: u64 = (vec::len(msg) * 8u) as u64;
|
||||
let orig_len: u64 = (msg.len() * 8u) as u64;
|
||||
|
||||
// pad message
|
||||
let mut msg = vec::append(vec::to_owned(msg), ~[0x80u8]);
|
||||
@ -51,7 +51,7 @@ pub fn md4(msg: &[u8]) -> Quad {
|
||||
}
|
||||
|
||||
let mut i = 0u;
|
||||
let e = vec::len(msg);
|
||||
let e = msg.len();
|
||||
let mut x = vec::from_elem(16u, 0u32);
|
||||
while i < e {
|
||||
let aa = a, bb = b, cc = c, dd = d;
|
||||
|
@ -15,7 +15,6 @@ use core::comm::{stream, SharedChan};
|
||||
use core::ptr;
|
||||
use core::result;
|
||||
use core::str;
|
||||
use core::vec;
|
||||
|
||||
use iotask = uv::iotask::IoTask;
|
||||
use interact = uv::iotask::interact;
|
||||
@ -340,7 +339,7 @@ extern fn get_addr_cb(handle: *uv_getaddrinfo_t,
|
||||
}
|
||||
}
|
||||
debug!("successful process addrinfo result, len: %?",
|
||||
vec::len(out_vec));
|
||||
out_vec.len());
|
||||
output_ch.send(result::Ok(out_vec));
|
||||
}
|
||||
else {
|
||||
@ -424,7 +423,7 @@ mod test {
|
||||
// this.. mostly just wanting to see it work, atm.
|
||||
let results = result::unwrap(ga_result);
|
||||
debug!("test_get_addr: Number of results for %s: %?",
|
||||
localhost_name, vec::len(results));
|
||||
localhost_name, results.len());
|
||||
for results.each |r| {
|
||||
let ipv_prefix = match *r {
|
||||
Ipv4(_) => ~"IPv4",
|
||||
|
@ -1802,7 +1802,7 @@ mod test {
|
||||
debug!("BUF_WRITE: val len %?", str::len(val));
|
||||
do str::byte_slice(val) |b_slice| {
|
||||
debug!("BUF_WRITE: b_slice len %?",
|
||||
vec::len(b_slice));
|
||||
b_slice.len());
|
||||
w.write(b_slice)
|
||||
}
|
||||
}
|
||||
@ -1810,7 +1810,7 @@ mod test {
|
||||
fn buf_read<R:io::Reader>(r: &R, len: uint) -> ~str {
|
||||
let new_bytes = (*r).read_bytes(len);
|
||||
debug!("in buf_read.. new_bytes len: %?",
|
||||
vec::len(new_bytes));
|
||||
new_bytes.len());
|
||||
str::from_bytes(new_bytes)
|
||||
}
|
||||
|
||||
@ -1863,7 +1863,7 @@ mod test {
|
||||
result::Ok(data) => {
|
||||
debug!("SERVER: got REQ str::from_bytes..");
|
||||
debug!("SERVER: REQ data len: %?",
|
||||
vec::len(data));
|
||||
data.len());
|
||||
server_ch.send(
|
||||
str::from_bytes(data));
|
||||
debug!("SERVER: before write");
|
||||
|
@ -58,9 +58,8 @@ fn map_slices<A:Copy + Owned,B:Copy + Owned>(
|
||||
info!("pre-slice: %?", (base, slice));
|
||||
let slice : &[A] =
|
||||
cast::transmute(slice);
|
||||
info!("slice: %?",
|
||||
(base, vec::len(slice), end - base));
|
||||
assert!((vec::len(slice) == end - base));
|
||||
info!("slice: %?", (base, slice.len(), end - base));
|
||||
assert!(slice.len() == end - base);
|
||||
f(base, slice)
|
||||
}
|
||||
};
|
||||
|
@ -164,7 +164,7 @@ pub fn append_rope(left: Rope, right: Rope) -> Rope {
|
||||
*/
|
||||
pub fn concat(v: ~[Rope]) -> Rope {
|
||||
//Copy `v` into a mut vector
|
||||
let mut len = vec::len(v);
|
||||
let mut len = v.len();
|
||||
if len == 0u { return node::Empty; }
|
||||
let mut ropes = vec::from_elem(len, v[0]);
|
||||
for uint::range(1u, len) |i| {
|
||||
@ -770,7 +770,7 @@ pub mod node {
|
||||
*/
|
||||
pub fn tree_from_forest_destructive(forest: &mut [@Node]) -> @Node {
|
||||
let mut i;
|
||||
let mut len = vec::len(forest);
|
||||
let mut len = forest.len();
|
||||
while len > 1u {
|
||||
i = 0u;
|
||||
while i < len - 1u {//Concat nodes 0 with 1, 2 with 3 etc.
|
||||
|
@ -90,8 +90,8 @@ pub fn sha1() -> @Sha1 {
|
||||
}
|
||||
}
|
||||
fn process_msg_block(st: &mut Sha1State) {
|
||||
assert!((vec::len(st.h) == digest_buf_len));
|
||||
assert!((vec::uniq_len(st.work_buf) == work_buf_len));
|
||||
assert!(st.h.len() == digest_buf_len);
|
||||
assert!(vec::uniq_len(st.work_buf) == work_buf_len);
|
||||
let mut t: int; // Loop counter
|
||||
let w = st.work_buf;
|
||||
|
||||
@ -230,7 +230,7 @@ pub fn sha1() -> @Sha1 {
|
||||
|
||||
impl Sha1 for Sha1State {
|
||||
fn reset(&mut self) {
|
||||
assert!((vec::len(self.h) == digest_buf_len));
|
||||
assert!(self.h.len() == digest_buf_len);
|
||||
self.len_low = 0u32;
|
||||
self.len_high = 0u32;
|
||||
self.msg_block_idx = 0u;
|
||||
|
@ -19,7 +19,6 @@ use core::unstable::sync::{Exclusive, exclusive};
|
||||
use core::ptr;
|
||||
use core::task;
|
||||
use core::util;
|
||||
use core::vec;
|
||||
|
||||
/****************************************************************************
|
||||
* Internals
|
||||
@ -220,7 +219,7 @@ pub impl<'self> Condvar<'self> {
|
||||
do task::unkillable {
|
||||
// Release lock, 'atomically' enqueuing ourselves in so doing.
|
||||
do (**self.sem).with |state| {
|
||||
if condvar_id < vec::len(state.blocked) {
|
||||
if condvar_id < state.blocked.len() {
|
||||
// Drop the lock.
|
||||
state.count += 1;
|
||||
if state.count <= 0 {
|
||||
@ -230,7 +229,7 @@ pub impl<'self> Condvar<'self> {
|
||||
let SignalEnd = SignalEnd.swap_unwrap();
|
||||
state.blocked[condvar_id].tail.send(SignalEnd);
|
||||
} else {
|
||||
out_of_bounds = Some(vec::len(state.blocked));
|
||||
out_of_bounds = Some(state.blocked.len());
|
||||
}
|
||||
}
|
||||
|
||||
@ -285,10 +284,10 @@ pub impl<'self> Condvar<'self> {
|
||||
let mut out_of_bounds = None;
|
||||
let mut result = false;
|
||||
do (**self.sem).with |state| {
|
||||
if condvar_id < vec::len(state.blocked) {
|
||||
if condvar_id < state.blocked.len() {
|
||||
result = signal_waitqueue(&state.blocked[condvar_id]);
|
||||
} else {
|
||||
out_of_bounds = Some(vec::len(state.blocked));
|
||||
out_of_bounds = Some(state.blocked.len());
|
||||
}
|
||||
}
|
||||
do check_cvar_bounds(out_of_bounds, condvar_id, "cond.signal_on()") {
|
||||
@ -304,14 +303,14 @@ pub impl<'self> Condvar<'self> {
|
||||
let mut out_of_bounds = None;
|
||||
let mut queue = None;
|
||||
do (**self.sem).with |state| {
|
||||
if condvar_id < vec::len(state.blocked) {
|
||||
if condvar_id < state.blocked.len() {
|
||||
// To avoid :broadcast_heavy, we make a new waitqueue,
|
||||
// swap it out with the old one, and broadcast on the
|
||||
// old one outside of the little-lock.
|
||||
queue = Some(util::replace(&mut state.blocked[condvar_id],
|
||||
new_waitqueue()));
|
||||
} else {
|
||||
out_of_bounds = Some(vec::len(state.blocked));
|
||||
out_of_bounds = Some(state.blocked.len());
|
||||
}
|
||||
}
|
||||
do check_cvar_bounds(out_of_bounds, condvar_id, "cond.signal_on()") {
|
||||
|
@ -144,7 +144,7 @@ pub fn parse_opts(args: &[~str]) -> OptRes {
|
||||
};
|
||||
|
||||
let filter =
|
||||
if vec::len(matches.free) > 0 {
|
||||
if matches.free.len() > 0 {
|
||||
option::Some(copy (matches).free[0])
|
||||
} else { option::None };
|
||||
|
||||
@ -901,7 +901,7 @@ mod tests {
|
||||
];
|
||||
let filtered = filter_tests(&opts, tests);
|
||||
|
||||
assert!((vec::len(filtered) == 1));
|
||||
assert!(filtered.len() == 1);
|
||||
assert!((filtered[0].desc.name.to_str() == ~"1"));
|
||||
assert!((filtered[0].desc.ignore == false));
|
||||
}
|
||||
|
@ -1358,7 +1358,7 @@ mod test {
|
||||
let req_msg_ptr: *u8 = vec::raw::to_ptr(req_str_bytes);
|
||||
debug!("req_msg ptr: %u", req_msg_ptr as uint);
|
||||
let req_msg = ~[
|
||||
buf_init(req_msg_ptr, vec::len(req_str_bytes))
|
||||
buf_init(req_msg_ptr, req_str_bytes.len())
|
||||
];
|
||||
// this is the enclosing record, we'll pass a ptr to
|
||||
// this to C..
|
||||
|
@ -232,7 +232,7 @@ fn highlight_lines(cm: @codemap::CodeMap,
|
||||
let max_lines = 6u;
|
||||
let mut elided = false;
|
||||
let mut display_lines = /* FIXME (#2543) */ copy lines.lines;
|
||||
if vec::len(display_lines) > max_lines {
|
||||
if display_lines.len() > max_lines {
|
||||
display_lines = vec::slice(display_lines, 0u, max_lines).to_vec();
|
||||
elided = true;
|
||||
}
|
||||
@ -243,7 +243,7 @@ fn highlight_lines(cm: @codemap::CodeMap,
|
||||
io::stderr().write_str(s);
|
||||
}
|
||||
if elided {
|
||||
let last_line = display_lines[vec::len(display_lines) - 1u];
|
||||
let last_line = display_lines[display_lines.len() - 1u];
|
||||
let s = fmt!("%s:%u ", fm.name, last_line + 1u);
|
||||
let mut indent = str::len(s);
|
||||
let mut out = ~"";
|
||||
@ -254,7 +254,7 @@ fn highlight_lines(cm: @codemap::CodeMap,
|
||||
|
||||
// FIXME (#3260)
|
||||
// If there's one line at fault we can easily point to the problem
|
||||
if vec::len(lines.lines) == 1u {
|
||||
if lines.lines.len() == 1u {
|
||||
let lo = cm.lookup_char_pos(sp.lo);
|
||||
let mut digits = 0u;
|
||||
let mut num = (lines.lines[0] + 1u) / 10u;
|
||||
|
@ -824,7 +824,7 @@ fn mk_struct_ser_impl(
|
||||
cx.ident_of("emit_struct"),
|
||||
~[
|
||||
cx.lit_str(span, @cx.str_of(ident)),
|
||||
cx.lit_uint(span, vec::len(fields)),
|
||||
cx.lit_uint(span, fields.len()),
|
||||
cx.lambda_stmts_1(span, fields, cx.ident_of("__s")),
|
||||
]
|
||||
);
|
||||
@ -886,7 +886,7 @@ fn mk_struct_deser_impl(
|
||||
cx.ident_of("read_struct"),
|
||||
~[
|
||||
cx.lit_str(span, @cx.str_of(ident)),
|
||||
cx.lit_uint(span, vec::len(fields)),
|
||||
cx.lit_uint(span, fields.len()),
|
||||
cx.lambda_expr_1(
|
||||
cx.expr(
|
||||
span,
|
||||
|
@ -351,7 +351,7 @@ pub fn expr_to_ident(cx: @ext_ctxt,
|
||||
err_msg: &str) -> ast::ident {
|
||||
match expr.node {
|
||||
ast::expr_path(p) => {
|
||||
if vec::len(p.types) > 0u || vec::len(p.idents) != 1u {
|
||||
if p.types.len() > 0u || p.idents.len() != 1u {
|
||||
cx.span_fatal(expr.span, err_msg);
|
||||
}
|
||||
return p.idents[0];
|
||||
|
@ -276,7 +276,7 @@ fn read_block_comment(rdr: @mut StringReader,
|
||||
|
||||
let mut style = if code_to_the_left { trailing } else { isolated };
|
||||
consume_non_eol_whitespace(rdr);
|
||||
if !is_eof(rdr) && rdr.curr != '\n' && vec::len(lines) == 1u {
|
||||
if !is_eof(rdr) && rdr.curr != '\n' && lines.len() == 1u {
|
||||
style = mixed;
|
||||
}
|
||||
debug!("<<< block comment");
|
||||
|
@ -2471,7 +2471,7 @@ pub impl Parser {
|
||||
}
|
||||
},
|
||||
_ => {
|
||||
if vec::len(enum_path.idents)==1u {
|
||||
if enum_path.idents.len()==1u {
|
||||
// it could still be either an enum
|
||||
// or an identifier pattern, resolve
|
||||
// will sort it out:
|
||||
@ -4337,7 +4337,7 @@ pub impl Parser {
|
||||
}
|
||||
_ => ()
|
||||
}
|
||||
let last = path[vec::len(path) - 1u];
|
||||
let last = path[path.len() - 1u];
|
||||
let path = @ast::Path { span: mk_sp(lo, self.span.hi),
|
||||
global: false,
|
||||
idents: path,
|
||||
|
@ -110,8 +110,8 @@ pub fn tok_str(t: token) -> ~str {
|
||||
|
||||
pub fn buf_str(toks: ~[token], szs: ~[int], left: uint, right: uint,
|
||||
lim: uint) -> ~str {
|
||||
let n = vec::len(toks);
|
||||
assert!(n == vec::len(szs));
|
||||
let n = toks.len();
|
||||
assert!(n == szs.len());
|
||||
let mut i = left;
|
||||
let mut L = lim;
|
||||
let mut s = ~"[";
|
||||
|
@ -1798,7 +1798,7 @@ pub fn print_meta_item(s: @ps, item: @ast::meta_item) {
|
||||
pub fn print_view_path(s: @ps, vp: @ast::view_path) {
|
||||
match vp.node {
|
||||
ast::view_path_simple(ident, path, _) => {
|
||||
if path.idents[vec::len(path.idents)-1u] != ident {
|
||||
if path.idents[path.idents.len()-1u] != ident {
|
||||
print_ident(s, ident);
|
||||
space(s.s);
|
||||
word_space(s, ~"=");
|
||||
@ -2067,7 +2067,7 @@ pub fn maybe_print_comment(s: @ps, pos: BytePos) {
|
||||
pub fn print_comment(s: @ps, cmnt: &comments::cmnt) {
|
||||
match cmnt.style {
|
||||
comments::mixed => {
|
||||
assert!((vec::len(cmnt.lines) == 1u));
|
||||
assert!(cmnt.lines.len() == 1u);
|
||||
zerobreak(s.s);
|
||||
word(s.s, cmnt.lines[0]);
|
||||
zerobreak(s.s);
|
||||
@ -2083,7 +2083,7 @@ pub fn print_comment(s: @ps, cmnt: &comments::cmnt) {
|
||||
}
|
||||
comments::trailing => {
|
||||
word(s.s, ~" ");
|
||||
if vec::len(cmnt.lines) == 1u {
|
||||
if cmnt.lines.len() == 1u {
|
||||
word(s.s, cmnt.lines[0]);
|
||||
hardbreak(s.s);
|
||||
} else {
|
||||
|
@ -13,7 +13,7 @@
|
||||
#[inline]
|
||||
pub fn iter<T>(v: &[T], f: &fn(&T)) {
|
||||
let mut i = 0u;
|
||||
let n = vec::len(v);
|
||||
let n = v.len();
|
||||
while i < n {
|
||||
f(&v[i]);
|
||||
i += 1u;
|
||||
|
@ -13,7 +13,7 @@
|
||||
// same as cci_iter_lib, more-or-less, but not marked inline
|
||||
pub fn iter(v: ~[uint], f: &fn(uint)) {
|
||||
let mut i = 0u;
|
||||
let n = vec::len(v);
|
||||
let n = v.len();
|
||||
while i < n {
|
||||
f(v[i]);
|
||||
i += 1u;
|
||||
|
@ -126,7 +126,7 @@ fn gen_search_keys(graph: &[~[node_id]], n: uint) -> ~[node_id] {
|
||||
*/
|
||||
fn bfs(graph: graph, key: node_id) -> bfs_result {
|
||||
let mut marks : ~[node_id]
|
||||
= vec::from_elem(vec::len(graph), -1i64);
|
||||
= vec::from_elem(graph.len(), -1i64);
|
||||
|
||||
let mut q = Deque::new();
|
||||
|
||||
@ -429,7 +429,7 @@ fn main() {
|
||||
let stop = time::precise_time_s();
|
||||
|
||||
io::stdout().write_line(fmt!("Generated %? edges in %? seconds.",
|
||||
vec::len(edges), stop - start));
|
||||
edges.len(), stop - start));
|
||||
|
||||
let start = time::precise_time_s();
|
||||
let graph = make_graph(1 << scale, copy edges);
|
||||
|
@ -95,7 +95,7 @@ fn windows_with_carry(bb: &[u8], nn: uint,
|
||||
it: &fn(window: &[u8])) -> ~[u8] {
|
||||
let mut ii = 0u;
|
||||
|
||||
let len = vec::len(bb);
|
||||
let len = bb.len();
|
||||
while ii < len - (nn - 1u) {
|
||||
it(vec::slice(bb, ii, ii+nn));
|
||||
ii += 1u;
|
||||
|
@ -70,7 +70,7 @@ pub impl Sudoku {
|
||||
let line = reader.read_line();
|
||||
let mut comps = ~[];
|
||||
for str::each_split_char(line.trim(), ',') |s| { comps.push(s.to_owned()) }
|
||||
if vec::len(comps) == 3u {
|
||||
if comps.len() == 3u {
|
||||
let row = uint::from_str(comps[0]).get() as u8;
|
||||
let col = uint::from_str(comps[1]).get() as u8;
|
||||
g[row][col] = uint::from_str(comps[2]).get() as u8;
|
||||
@ -103,7 +103,7 @@ pub impl Sudoku {
|
||||
}
|
||||
|
||||
let mut ptr = 0u;
|
||||
let end = vec::len(work);
|
||||
let end = work.len();
|
||||
while (ptr < end) {
|
||||
let (row, col) = work[ptr];
|
||||
// is there another color to try?
|
||||
@ -265,7 +265,7 @@ fn check_default_sudoku_solution() {
|
||||
|
||||
fn main() {
|
||||
let args = os::args();
|
||||
let use_default = vec::len(args) == 1u;
|
||||
let use_default = args.len() == 1u;
|
||||
let mut sudoku = if use_default {
|
||||
Sudoku::from_vec(&default_sudoku)
|
||||
} else {
|
||||
|
@ -39,15 +39,15 @@ pub fn main() {
|
||||
// Call a method
|
||||
for x.iterate() |y| { assert!(x[*y] == *y); }
|
||||
// Call a parameterized function
|
||||
assert!(length(x.clone()) == vec::len(x));
|
||||
assert!(length(x.clone()) == x.len());
|
||||
// Call a parameterized function, with type arguments that require
|
||||
// a borrow
|
||||
assert!(length::<int, &[int]>(x) == vec::len(x));
|
||||
assert!(length::<int, &[int]>(x) == x.len());
|
||||
|
||||
// Now try it with a type that *needs* to be borrowed
|
||||
let z = [0,1,2,3];
|
||||
// Call a method
|
||||
for z.iterate() |y| { assert!(z[*y] == *y); }
|
||||
// Call a parameterized function
|
||||
assert!(length::<int, &[int]>(z) == vec::len(z));
|
||||
assert!(length::<int, &[int]>(z) == z.len());
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ fn annoy_neighbors<T:noisy>(critter: T) {
|
||||
|
||||
fn bite_everything<T:bitey>(critter: T) -> bool {
|
||||
let mut left : ~[body_part] = ~[finger, toe, nose, ear];
|
||||
while vec::len(left) > 0u {
|
||||
while left.len() > 0u {
|
||||
let part = critter.bite();
|
||||
debug!("%? %?", left, part);
|
||||
if vec_includes(left, part) {
|
||||
|
@ -71,7 +71,7 @@ mod map_reduce {
|
||||
|
||||
start_mappers(ctrl_chan, inputs.clone());
|
||||
|
||||
let mut num_mappers = vec::len(inputs) as int;
|
||||
let mut num_mappers = inputs.len() as int;
|
||||
|
||||
while num_mappers > 0 {
|
||||
match ctrl_port.recv() {
|
||||
|
@ -14,7 +14,7 @@ fn test_heap_to_heap() {
|
||||
// a spills onto the heap
|
||||
let mut a = ~[0, 1, 2, 3, 4];
|
||||
a = a + a; // FIXME(#3387)---can't write a += a
|
||||
assert!((vec::len(a) == 10u));
|
||||
assert!(a.len() == 10u);
|
||||
assert!((a[0] == 0));
|
||||
assert!((a[1] == 1));
|
||||
assert!((a[2] == 2));
|
||||
@ -32,7 +32,7 @@ fn test_stack_to_heap() {
|
||||
let mut a = ~[0, 1, 2];
|
||||
// a spills to the heap
|
||||
a = a + a; // FIXME(#3387)---can't write a += a
|
||||
assert!((vec::len(a) == 6u));
|
||||
assert!(a.len() == 6u);
|
||||
assert!((a[0] == 0));
|
||||
assert!((a[1] == 1));
|
||||
assert!((a[2] == 2));
|
||||
@ -47,8 +47,8 @@ fn test_loop() {
|
||||
let mut i = 20;
|
||||
let mut expected_len = 1u;
|
||||
while i > 0 {
|
||||
error!(vec::len(a));
|
||||
assert!((vec::len(a) == expected_len));
|
||||
error!(a.len());
|
||||
assert!(a.len() == expected_len);
|
||||
a = a + a; // FIXME(#3387)---can't write a += a
|
||||
i -= 1;
|
||||
expected_len *= 2u;
|
||||
|
Loading…
Reference in New Issue
Block a user