Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
ee2a11eb
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ee2a11eb
编写于
8月 23, 2011
作者:
B
Brian Anderson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Convert std::uint to istrs. Issue #855
上级
69e6abf9
变更
19
隐藏空白更改
内联
并排
Showing
19 changed file
with
99 addition
and
73 deletion
+99
-73
src/comp/metadata/tyencode.rs
src/comp/metadata/tyencode.rs
+5
-4
src/comp/middle/trans.rs
src/comp/middle/trans.rs
+8
-7
src/comp/middle/trans_common.rs
src/comp/middle/trans_common.rs
+2
-1
src/comp/middle/tstate/annotate.rs
src/comp/middle/tstate/annotate.rs
+2
-1
src/comp/middle/tstate/auxiliary.rs
src/comp/middle/tstate/auxiliary.rs
+2
-1
src/comp/middle/tstate/collect_locals.rs
src/comp/middle/tstate/collect_locals.rs
+6
-3
src/comp/middle/ty.rs
src/comp/middle/ty.rs
+15
-10
src/comp/syntax/parse/token.rs
src/comp/syntax/parse/token.rs
+2
-1
src/comp/syntax/print/pprust.rs
src/comp/syntax/print/pprust.rs
+3
-2
src/comp/util/common.rs
src/comp/util/common.rs
+3
-2
src/lib/ebml.rs
src/lib/ebml.rs
+2
-1
src/lib/extfmt.rs
src/lib/extfmt.rs
+1
-1
src/lib/int.rs
src/lib/int.rs
+2
-2
src/lib/io.rs
src/lib/io.rs
+2
-1
src/lib/istr.rs
src/lib/istr.rs
+2
-1
src/lib/net.rs
src/lib/net.rs
+3
-1
src/lib/sha1.rs
src/lib/sha1.rs
+3
-1
src/lib/uint.rs
src/lib/uint.rs
+9
-9
src/test/stdtest/map.rs
src/test/stdtest/map.rs
+27
-24
未找到文件。
src/comp/metadata/tyencode.rs
浏览文件 @
ee2a11eb
// Type encoding
import
std
::
istr
;
import
std
::
io
;
import
std
::
map
::
hashmap
;
import
std
::
option
::
some
;
...
...
@@ -70,9 +71,9 @@ fn estimate_sz(u: uint) -> uint {
// I.e. it's actually an abbreviation.
let
s
=
"#"
+
uint
::
to_str
(
pos
,
16u
)
+
":"
+
uint
::
to_str
(
len
,
16u
)
+
"#"
;
let
a
=
{
pos
:
pos
,
len
:
len
,
s
:
s
};
~
"#"
+
uint
::
to_str
(
pos
,
16u
)
+
~
":"
+
uint
::
to_str
(
len
,
16u
)
+
~
"#"
;
let
a
=
{
pos
:
pos
,
len
:
len
,
s
:
istr
::
to_estr
(
s
)
};
abbrevs
.insert
(
t
,
a
);
}
ret
;
...
...
@@ -183,7 +184,7 @@ fn enc_sty(w: &io::writer, cx: &@ctxt, st: &ty::sty) {
kind_shared
.
{
w
.write_str
(
"ps"
);
}
kind_pinned
.
{
w
.write_str
(
"pp"
);
}
}
w
.write_str
(
uint
::
str
(
id
));
w
.write_str
(
istr
::
to_estr
(
uint
::
str
(
id
)
));
}
ty
::
ty_type
.
{
w
.write_char
(
'Y'
);
}
ty
::
ty_constr
(
ty
,
cs
)
{
...
...
src/comp/middle/trans.rs
浏览文件 @
ee2a11eb
...
...
@@ -14,6 +14,7 @@
// int) and rec(x=int, y=int, z=int) will have the same TypeRef.
import
std
::
int
;
import
std
::
str
;
import
std
::
istr
;
import
std
::
uint
;
import
std
::
str
::
rustrt
::
sbuf
;
import
std
::
map
;
...
...
@@ -1048,10 +1049,10 @@ fn get_tydesc(cx: &@block_ctxt, orig_t: ty::t, escapes: bool,
}
else
{
bcx_tcx
(
cx
)
.sess
.span_bug
(
cx
.sp
,
"Unbound typaram in get_tydesc: "
+
"orig_t = "
+
ty_to_str
(
bcx_tcx
(
cx
),
orig_t
)
+
" ty_param = "
+
std
::
uint
::
str
(
id
));
"orig_t = "
+
ty_to_str
(
bcx_tcx
(
cx
),
orig_t
)
+
" ty_param = "
+
istr
::
to_estr
(
std
::
uint
::
str
(
id
)
));
}
}
none
.
{
/* fall through */
}
...
...
@@ -1871,8 +1872,8 @@ fn iter_variant(cx: @block_ctxt, a_tup: ValueRef,
for
variant
:
ty
::
variant_info
in
variants
{
let
variant_cx
=
new_sub_block_ctxt
(
bcx
,
"tag-iter-variant-"
+
uint
::
to_str
(
i
,
10u
));
istr
::
to_estr
(
~
"tag-iter-variant-"
+
uint
::
to_str
(
i
,
10u
)
));
llvm
::
LLVMAddCase
(
llswitch
,
C_int
(
i
as
int
),
variant_cx
.llbb
);
variant_cx
=
iter_variant
(
variant_cx
,
llunion_a_ptr
,
variant
,
tps
,
tid
,
...
...
@@ -5517,7 +5518,7 @@ fn trans_tag_variant(cx: @local_ctxt, tag_id: ast::node_id,
fn_args
+=
[{
mode
:
ast
::
alias
(
false
),
ty
:
varg
.ty
,
ident
:
"arg"
+
uint
::
to_str
(
i
,
10u
),
ident
:
istr
::
to_estr
(
~
"arg"
+
uint
::
to_str
(
i
,
10u
)
),
id
:
varg
.id
}];
}
assert
(
cx
.ccx.item_ids
.contains_key
(
variant
.node.id
));
...
...
src/comp/middle/trans_common.rs
浏览文件 @
ee2a11eb
...
...
@@ -6,6 +6,7 @@
import
std
::
int
;
import
std
::
vec
;
import
std
::
str
;
import
std
::
istr
;
import
std
::
uint
;
import
std
::
str
::
rustrt
::
sbuf
;
import
std
::
map
;
...
...
@@ -758,7 +759,7 @@ fn T_opaque_closure_ptr(cx: &crate_ctxt) -> TypeRef {
}
fn
T_tag
(
tn
:
&
type_names
,
size
:
uint
)
->
TypeRef
{
let
s
=
"tag_"
+
uint
::
to_str
(
size
,
10u
);
let
s
=
"tag_"
+
istr
::
to_estr
(
uint
::
to_str
(
size
,
10u
)
);
if
tn
.name_has_type
(
s
)
{
ret
tn
.get_type
(
s
);
}
let
t
=
T_struct
([
T_int
(),
T_array
(
T_i8
(),
size
)]);
tn
.associate
(
s
,
t
);
...
...
src/comp/middle/tstate/annotate.rs
浏览文件 @
ee2a11eb
...
...
@@ -4,6 +4,7 @@
import
std
::
option
::
none
;
import
std
::
int
;
import
std
::
uint
;
import
std
::
istr
;
import
syntax
::
ast
::
*
;
import
syntax
::
ast_util
::
pat_binding_ids
;
import
syntax
::
visit
;
...
...
@@ -61,7 +62,7 @@ fn node_ids_in_fn(f: &_fn, tps: &[ty_param], sp: &span, i: &fn_ident,
fn
init_vecs
(
ccx
:
&
crate_ctxt
,
node_ids
:
&
[
node_id
],
len
:
uint
)
{
for
i
:
node_id
in
node_ids
{
log
int
::
str
(
i
)
+
" |-> "
+
uint
::
str
(
len
);
log
int
::
str
(
i
)
+
" |-> "
+
istr
::
to_estr
(
uint
::
str
(
len
)
);
add_node
(
ccx
,
i
,
empty_ann
(
len
));
}
}
...
...
src/comp/middle/tstate/auxiliary.rs
浏览文件 @
ee2a11eb
import
std
::
vec
;
import
std
::
int
::
str
;
import
std
::
str
;
import
std
::
istr
;
import
std
::
option
;
import
std
::
option
::
*
;
import
std
::
int
;
...
...
@@ -678,7 +679,7 @@ fn expr_to_constr(tcx: ty::ctxt, e: &@expr) -> sp_constr {
}
fn
pred_args_to_str
(
p
:
&
pred_args
)
->
str
{
"<"
+
uint
::
str
(
p
.node.bit_num
)
+
", "
+
"<"
+
istr
::
to_estr
(
uint
::
str
(
p
.node.bit_num
)
)
+
", "
+
constr_args_to_str
(
fn
(
i
:
&
inst
)
->
str
{
ret
i
.ident
;
},
p
.node.args
)
+
">"
}
...
...
src/comp/middle/tstate/collect_locals.rs
浏览文件 @
ee2a11eb
import
std
::
istr
;
import
std
::
uint
;
import
std
::
int
;
import
std
::
vec
;
...
...
@@ -60,7 +61,8 @@ fn find_locals(tcx: &ty::ctxt, f: &_fn, tps: &[ty_param], sp: &span,
fn
add_constraint
(
tcx
:
&
ty
::
ctxt
,
c
:
sp_constr
,
next
:
uint
,
tbl
:
constr_map
)
->
uint
{
log
constraint_to_str
(
tcx
,
c
)
+
" |-> "
+
std
::
uint
::
str
(
next
);
log
constraint_to_str
(
tcx
,
c
)
+
" |-> "
+
istr
::
to_estr
(
std
::
uint
::
str
(
next
));
alt
c
.node
{
ninit
(
id
,
i
)
{
tbl
.insert
(
local_def
(
id
),
cinit
(
next
,
c
.span
,
i
));
}
npred
(
p
,
d_id
,
args
)
{
...
...
@@ -145,8 +147,9 @@ fn mk_fn_info(ccx: &crate_ctxt, f: &_fn, tp: &[ty_param], f_sp: &span,
i_diverge
:
ninit
(
diverges_id
,
diverges_name
),
used_vars
:
v
};
ccx
.fm
.insert
(
id
,
rslt
);
log
name
+
" has "
+
std
::
uint
::
str
(
num_constraints
(
rslt
))
+
" constraints"
;
log
name
+
istr
::
to_estr
(
~
" has "
+
std
::
uint
::
str
(
num_constraints
(
rslt
))
+
~
" constraints"
);
}
...
...
src/comp/middle/ty.rs
浏览文件 @
ee2a11eb
import
std
::
int
;
import
std
::
vec
;
import
std
::
str
;
import
std
::
istr
;
import
std
::
uint
;
import
std
::
box
;
import
std
::
ufind
;
...
...
@@ -2605,14 +2606,18 @@ fn type_err_to_str(err: &ty::type_err) -> str {
terr_box_mutability
.
{
ret
"boxed values differ in mutability"
;
}
terr_vec_mutability
.
{
ret
"vectors differ in mutability"
;
}
terr_tuple_size
(
e_sz
,
a_sz
)
{
ret
"expected a tuple with "
+
uint
::
to_str
(
e_sz
,
10u
)
+
" elements but found one with "
+
uint
::
to_str
(
a_sz
,
10u
)
+
" elements"
;
ret
istr
::
to_estr
(
~
"expected a tuple with "
+
uint
::
to_str
(
e_sz
,
10u
)
+
~
" elements but found one with "
+
uint
::
to_str
(
a_sz
,
10u
)
+
~
" elements"
);
}
terr_record_size
(
e_sz
,
a_sz
)
{
ret
"expected a record with "
+
uint
::
to_str
(
e_sz
,
10u
)
+
" fields but found one with "
+
uint
::
to_str
(
a_sz
,
10u
)
+
" fields"
;
ret
istr
::
to_estr
(
~
"expected a record with "
+
uint
::
to_str
(
e_sz
,
10u
)
+
~
" fields but found one with "
+
uint
::
to_str
(
a_sz
,
10u
)
+
~
" fields"
);
}
terr_record_mutability
.
{
ret
"record elements differ in mutability"
;
}
terr_record_fields
(
e_fld
,
a_fld
)
{
...
...
@@ -2630,10 +2635,10 @@ fn type_err_to_str(err: &ty::type_err) -> str {
mode_str_1
(
a_mode
);
}
terr_constr_len
(
e_len
,
a_len
)
{
ret
"Expected a type with "
+
uint
::
str
(
e_len
)
+
" constraints,
\
but found one with "
+
uint
::
str
(
a_len
)
+
" constraints"
;
ret
istr
::
to_estr
(
~
"Expected a type with "
+
uint
::
str
(
e_len
)
+
~
" constraints,
but found one with "
+
uint
::
str
(
a_len
)
+
~
" constraints"
)
;
}
terr_constr_mismatch
(
e_constr
,
a_constr
)
{
ret
"Expected a type with constraint "
+
ty_constr_to_str
(
e_constr
)
+
...
...
src/comp/syntax/parse/token.rs
浏览文件 @
ee2a11eb
...
...
@@ -6,6 +6,7 @@
import
std
::
int
;
import
std
::
uint
;
import
std
::
str
;
import
std
::
istr
;
type
str_num
=
uint
;
...
...
@@ -146,7 +147,7 @@ fn to_str(r: lexer::reader, t: token) -> str {
LIT_INT
(
i
)
{
ret
int
::
to_str
(
i
,
10u
);
}
LIT_UINT
(
u
)
{
ret
uint
::
to_str
(
u
,
10u
);
}
LIT_UINT
(
u
)
{
ret
istr
::
to_estr
(
uint
::
to_str
(
u
,
10u
)
);
}
LIT_MACH_INT
(
tm
,
i
)
{
ret
int
::
to_str
(
i
,
10u
)
+
"_"
+
ty_mach_to_str
(
tm
);
}
...
...
src/comp/syntax/print/pprust.rs
浏览文件 @
ee2a11eb
...
...
@@ -3,6 +3,7 @@
import
std
::
int
;
import
std
::
io
;
import
std
::
str
;
import
std
::
istr
;
import
std
::
uint
;
import
std
::
option
;
import
parse
::
lexer
;
...
...
@@ -1498,7 +1499,7 @@ fn print_literal(s: &ps, lit: &@ast::lit) {
"'"
);
}
ast
::
lit_int
(
val
)
{
word
(
s
.s
,
int
::
str
(
val
));
}
ast
::
lit_uint
(
val
)
{
word
(
s
.s
,
uint
::
str
(
val
)
+
"u"
);
}
ast
::
lit_uint
(
val
)
{
word
(
s
.s
,
istr
::
to_estr
(
uint
::
str
(
val
)
)
+
"u"
);
}
ast
::
lit_float
(
fstr
)
{
word
(
s
.s
,
fstr
);
}
ast
::
lit_mach_int
(
mach
,
val
)
{
word
(
s
.s
,
int
::
str
(
val
as
int
));
...
...
@@ -1660,7 +1661,7 @@ fn constr_arg_to_str<T>(f: &fn(&T) -> str, c: &ast::constr_arg_general_<T>) ->
// needed b/c constr_args_to_str needs
// something that takes an alias
// (argh)
fn
uint_to_str
(
i
:
&
uint
)
->
str
{
ret
uint
::
str
(
i
);
}
fn
uint_to_str
(
i
:
&
uint
)
->
str
{
ret
istr
::
to_estr
(
uint
::
str
(
i
)
);
}
fn
ast_ty_fn_constr_to_str
(
c
:
&@
ast
::
constr
)
->
str
{
ret
path_to_str
(
c
.node.path
)
+
...
...
src/comp/util/common.rs
浏览文件 @
ee2a11eb
import
std
::
str
;
import
std
::
istr
;
import
std
::
map
;
import
std
::
map
::
hashmap
;
import
std
::
uint
;
...
...
@@ -163,13 +164,13 @@ fn float_to_str(num: float, digits: uint) -> str {
let
accum
=
if
num
<
0.0
{
num
=
-
num
;
"-"
}
else
{
""
};
let
trunc
=
num
as
uint
;
let
frac
=
num
-
(
trunc
as
float
);
accum
+=
uint
::
str
(
trunc
);
accum
+=
istr
::
to_estr
(
uint
::
str
(
trunc
)
);
if
frac
==
0.0
||
digits
==
0u
{
ret
accum
;
}
accum
+=
"."
;
while
digits
>
0u
&&
frac
>
0.0
{
frac
*=
10.0
;
let
digit
=
frac
as
uint
;
accum
+=
uint
::
str
(
digit
);
accum
+=
istr
::
to_estr
(
uint
::
str
(
digit
)
);
frac
-=
digit
as
float
;
digits
-=
1u
;
}
...
...
src/lib/ebml.rs
浏览文件 @
ee2a11eb
...
...
@@ -67,7 +67,8 @@ fn get_doc(d: doc, tg: uint) -> doc {
alt
maybe_get_doc
(
d
,
tg
)
{
some
(
d
)
{
ret
d
;
}
none
.
{
log_err
"failed to find block with tag "
+
uint
::
to_str
(
tg
,
10u
);
log_err
"failed to find block with tag "
+
istr
::
to_estr
(
uint
::
to_str
(
tg
,
10u
));
fail
;
}
}
...
...
src/lib/extfmt.rs
浏览文件 @
ee2a11eb
...
...
@@ -337,7 +337,7 @@ fn uint_to_str_prec(num: uint, radix: uint, prec: uint) -> str {
ret
if
prec
==
0u
&&
num
==
0u
{
""
}
else
{
let
s
=
uint
::
to_str
(
num
,
radix
);
let
s
=
istr
::
to_estr
(
uint
::
to_str
(
num
,
radix
)
);
let
len
=
str
::
char_len
(
s
);
if
len
<
prec
{
let
diff
=
prec
-
len
;
...
...
src/lib/int.rs
浏览文件 @
ee2a11eb
...
...
@@ -44,8 +44,8 @@
fn
to_str
(
n
:
int
,
radix
:
uint
)
->
str
{
assert
(
0u
<
radix
&&
radix
<=
16u
);
ret
if
n
<
0
{
"-"
+
uint
::
to_str
(
-
n
as
uint
,
radix
)
}
else
{
uint
::
to_str
(
n
as
uint
,
radix
)
};
"-"
+
istr
::
to_estr
(
uint
::
to_str
(
-
n
as
uint
,
radix
)
)
}
else
{
istr
::
to_estr
(
uint
::
to_str
(
n
as
uint
,
radix
)
)
};
}
fn
str
(
i
:
int
)
->
str
{
ret
to_str
(
i
,
10u
);
}
...
...
src/lib/io.rs
浏览文件 @
ee2a11eb
...
...
@@ -338,7 +338,8 @@ fn write_char(ch: char) {
out
.write
(
str
::
bytes
(
str
::
from_char
(
ch
)));
}
fn
write_int
(
n
:
int
)
{
out
.write
(
str
::
bytes
(
int
::
to_str
(
n
,
10u
)));
}
fn
write_uint
(
n
:
uint
)
{
out
.write
(
str
::
bytes
(
uint
::
to_str
(
n
,
10u
)));
}
fn
write_uint
(
n
:
uint
)
{
out
.write
(
str
::
bytes
(
istr
::
to_estr
(
uint
::
to_str
(
n
,
10u
))));
}
fn
write_bytes
(
bytes
:
&
[
u8
])
{
out
.write
(
bytes
);
}
fn
write_le_uint
(
n
:
uint
,
size
:
uint
)
{
out
.write
(
uint_to_le_bytes
(
n
,
size
));
...
...
src/lib/istr.rs
浏览文件 @
ee2a11eb
...
...
@@ -2,7 +2,8 @@
index
,
rindex
,
find
,
starts_with
,
ends_with
,
substr
,
slice
,
split
,
concat
,
connect
,
to_upper
,
replace
,
char_slice
,
trim_left
,
trim_right
,
trim
,
unshift_char
,
shift_char
,
pop_char
,
push_char
,
is_utf8
,
from_chars
,
to_chars
,
char_len
,
char_at
,
bytes
,
is_ascii
,
shift_byte
,
pop_byte
,
unsafe_from_bytes
;
char_len
,
char_at
,
bytes
,
is_ascii
,
shift_byte
,
pop_byte
,
unsafe_from_byte
,
unsafe_from_bytes
;
export
from_estr
,
to_estr
;
...
...
src/lib/net.rs
浏览文件 @
ee2a11eb
...
...
@@ -14,7 +14,9 @@ fn format_addr(ip: ip_addr) -> str {
}
fn
parse_addr
(
ip
:
str
)
->
ip_addr
{
let
parts
=
vec
::
map
(
uint
::
from_str
,
str
::
split
(
ip
,
"."
[
0
]));
let
parts
=
vec
::
map
(
{
|
&
s
|
uint
::
from_str
(
istr
::
from_estr
(
s
))
},
str
::
split
(
ip
,
"."
[
0
]));
if
vec
::
len
(
parts
)
!=
4u
{
fail
"Too many dots in IP address"
;
}
for
i
in
parts
{
if
i
>
255u
{
fail
"Invalid IP Address part."
;
}
}
ipv4
(
parts
[
0
]
as
u8
,
parts
[
1
]
as
u8
,
parts
[
2
]
as
u8
,
parts
[
3
]
as
u8
)
...
...
src/lib/sha1.rs
浏览文件 @
ee2a11eb
...
...
@@ -220,7 +220,9 @@ fn reset() {
fn
result_str
()
->
str
{
let
r
=
mk_result
(
st
);
let
s
=
""
;
for
b
:
u8
in
r
{
s
+=
uint
::
to_str
(
b
as
uint
,
16u
);
}
for
b
:
u8
in
r
{
s
+=
istr
::
to_estr
(
uint
::
to_str
(
b
as
uint
,
16u
));
}
ret
s
;
}
}
...
...
src/lib/uint.rs
浏览文件 @
ee2a11eb
...
...
@@ -56,9 +56,9 @@ fn parse_buf(buf: &[u8], radix: uint) -> uint {
fail
;
}
fn
from_str
(
s
:
&
str
)
->
uint
{
parse_buf
(
str
::
bytes
(
s
),
10u
)
}
fn
from_str
(
s
:
&
istr
)
->
uint
{
parse_buf
(
i
str
::
bytes
(
s
),
10u
)
}
fn
to_str
(
num
:
uint
,
radix
:
uint
)
->
str
{
fn
to_str
(
num
:
uint
,
radix
:
uint
)
->
i
str
{
let
n
=
num
;
assert
(
0u
<
radix
&&
radix
<=
16u
);
fn
digit
(
n
:
uint
)
->
char
{
...
...
@@ -82,18 +82,18 @@ fn digit(n: uint) -> char {
_
{
fail
}
};
}
if
n
==
0u
{
ret
"0"
;
}
let
s
:
str
=
""
;
if
n
==
0u
{
ret
~
"0"
;
}
let
s
:
istr
=
~
""
;
while
n
!=
0u
{
s
+=
str
::
unsafe_from_byte
(
digit
(
n
%
radix
)
as
u8
);
s
+=
i
str
::
unsafe_from_byte
(
digit
(
n
%
radix
)
as
u8
);
n
/=
radix
;
}
let
s1
:
str
=
""
;
let
len
:
uint
=
str
::
byte_len
(
s
);
while
len
!=
0u
{
len
-=
1u
;
s1
+=
str
::
unsafe_from_byte
(
s
[
len
]);
}
let
s1
:
istr
=
~
""
;
let
len
:
uint
=
i
str
::
byte_len
(
s
);
while
len
!=
0u
{
len
-=
1u
;
s1
+=
i
str
::
unsafe_from_byte
(
s
[
len
]);
}
ret
s1
;
}
fn
str
(
i
:
uint
)
->
str
{
ret
to_str
(
i
,
10u
);
}
fn
str
(
i
:
uint
)
->
i
str
{
ret
to_str
(
i
,
10u
);
}
// Local Variables:
// mode: rust;
...
...
src/test/stdtest/map.rs
浏览文件 @
ee2a11eb
...
...
@@ -4,6 +4,7 @@
use
std
;
import
std
::
map
;
import
std
::
str
;
import
std
::
istr
;
import
std
::
uint
;
import
std
::
util
;
import
std
::
option
;
...
...
@@ -92,14 +93,14 @@ fn test_growth() {
let
i
:
uint
=
0u
;
while
i
<
num_to_insert
{
assert
(
hm_uu
.insert
(
i
,
i
*
i
));
log
"inserting "
+
uint
::
to_str
(
i
,
10u
)
+
" -> "
+
log
~
"inserting "
+
uint
::
to_str
(
i
,
10u
)
+
~
" -> "
+
uint
::
to_str
(
i
*
i
,
10u
);
i
+=
1u
;
}
log
"-----"
;
i
=
0u
;
while
i
<
num_to_insert
{
log
"get("
+
uint
::
to_str
(
i
,
10u
)
+
") = "
+
log
~
"get("
+
uint
::
to_str
(
i
,
10u
)
+
~
") = "
+
uint
::
to_str
(
hm_uu
.get
(
i
),
10u
);
assert
(
hm_uu
.get
(
i
)
==
i
*
i
);
i
+=
1u
;
...
...
@@ -110,7 +111,7 @@ fn test_growth() {
hm_uu
.rehash
();
i
=
0u
;
while
i
<
num_to_insert
{
log
"get("
+
uint
::
to_str
(
i
,
10u
)
+
") = "
+
log
~
"get("
+
uint
::
to_str
(
i
,
10u
)
+
~
") = "
+
uint
::
to_str
(
hm_uu
.get
(
i
),
10u
);
assert
(
hm_uu
.get
(
i
)
==
i
*
i
);
i
+=
1u
;
...
...
@@ -122,32 +123,34 @@ fn test_growth() {
map
::
mk_hashmap
::
<
str
,
str
>
(
hasher_str
,
eqer_str
);
i
=
0u
;
while
i
<
num_to_insert
{
assert
(
hm_ss
.insert
(
uint
::
to_str
(
i
,
2u
),
uint
::
to_str
(
i
*
i
,
2u
)));
log
"inserting
\"
"
+
uint
::
to_str
(
i
,
2u
)
+
"
\"
->
\"
"
+
uint
::
to_str
(
i
*
i
,
2u
)
+
"
\"
"
;
assert
(
hm_ss
.insert
(
istr
::
to_estr
(
uint
::
to_str
(
i
,
2u
)),
istr
::
to_estr
(
uint
::
to_str
(
i
*
i
,
2u
))));
log
~
"inserting
\"
"
+
uint
::
to_str
(
i
,
2u
)
+
~
"
\"
->
\"
"
+
uint
::
to_str
(
i
*
i
,
2u
)
+
~
"
\"
"
;
i
+=
1u
;
}
log
"-----"
;
i
=
0u
;
while
i
<
num_to_insert
{
log
"get(
\"
"
+
uint
::
to_str
(
i
,
2u
)
+
"
\"
) =
\"
"
+
hm_ss
.get
(
uint
::
to_str
(
i
,
2u
))
+
"
\"
"
;
assert
(
str
::
eq
(
hm_ss
.get
(
uint
::
to_str
(
i
,
2u
)),
uint
::
to_str
(
i
*
i
,
2u
)));
log
"get(
\"
"
+
istr
::
to_estr
(
uint
::
to_str
(
i
,
2u
)
)
+
"
\"
) =
\"
"
+
hm_ss
.get
(
istr
::
to_estr
(
uint
::
to_str
(
i
,
2u
)
))
+
"
\"
"
;
assert
(
str
::
eq
(
hm_ss
.get
(
istr
::
to_estr
(
uint
::
to_str
(
i
,
2u
)
)),
istr
::
to_estr
(
uint
::
to_str
(
i
*
i
,
2u
)
)));
i
+=
1u
;
}
assert
(
hm_ss
.insert
(
uint
::
to_str
(
num_to_insert
,
2u
),
uint
::
to_str
(
17u
,
2u
)));
assert
(
str
::
eq
(
hm_ss
.get
(
uint
::
to_str
(
num_to_insert
,
2u
)),
uint
::
to_str
(
17u
,
2u
)));
assert
(
hm_ss
.insert
(
istr
::
to_estr
(
uint
::
to_str
(
num_to_insert
,
2u
)),
istr
::
to_estr
(
uint
::
to_str
(
17u
,
2u
))));
assert
(
str
::
eq
(
hm_ss
.get
(
istr
::
to_estr
(
uint
::
to_str
(
num_to_insert
,
2u
))),
istr
::
to_estr
(
uint
::
to_str
(
17u
,
2u
))));
log
"-----"
;
hm_ss
.rehash
();
i
=
0u
;
while
i
<
num_to_insert
{
log
"get(
\"
"
+
uint
::
to_str
(
i
,
2u
)
+
"
\"
) =
\"
"
+
hm_ss
.get
(
uint
::
to_str
(
i
,
2u
))
+
"
\"
"
;
assert
(
str
::
eq
(
hm_ss
.get
(
uint
::
to_str
(
i
,
2u
)),
uint
::
to_str
(
i
*
i
,
2u
)));
log
"get(
\"
"
+
istr
::
to_estr
(
uint
::
to_str
(
i
,
2u
)
)
+
"
\"
) =
\"
"
+
hm_ss
.get
(
istr
::
to_estr
(
uint
::
to_str
(
i
,
2u
)
))
+
"
\"
"
;
assert
(
str
::
eq
(
hm_ss
.get
(
istr
::
to_estr
(
uint
::
to_str
(
i
,
2u
)
)),
istr
::
to_estr
(
uint
::
to_str
(
i
*
i
,
2u
)
)));
i
+=
1u
;
}
log
"*** finished test_growth"
;
...
...
@@ -174,7 +177,7 @@ fn hash(u: &uint) -> uint {
let
i
:
uint
=
0u
;
while
i
<
num_to_insert
{
assert
(
hm
.insert
(
i
,
i
*
i
));
log
"inserting "
+
uint
::
to_str
(
i
,
10u
)
+
" -> "
+
log
~
"inserting "
+
uint
::
to_str
(
i
,
10u
)
+
~
" -> "
+
uint
::
to_str
(
i
*
i
,
10u
);
i
+=
1u
;
}
...
...
@@ -196,7 +199,7 @@ fn hash(u: &uint) -> uint {
log
"-----"
;
i
=
1u
;
while
i
<
num_to_insert
{
log
"get("
+
uint
::
to_str
(
i
,
10u
)
+
") = "
+
log
~
"get("
+
uint
::
to_str
(
i
,
10u
)
+
~
") = "
+
uint
::
to_str
(
hm
.get
(
i
),
10u
);
assert
(
hm
.get
(
i
)
==
i
*
i
);
i
+=
2u
;
...
...
@@ -207,7 +210,7 @@ fn hash(u: &uint) -> uint {
log
"-----"
;
i
=
1u
;
while
i
<
num_to_insert
{
log
"get("
+
uint
::
to_str
(
i
,
10u
)
+
") = "
+
log
~
"get("
+
uint
::
to_str
(
i
,
10u
)
+
~
") = "
+
uint
::
to_str
(
hm
.get
(
i
),
10u
);
assert
(
hm
.get
(
i
)
==
i
*
i
);
i
+=
2u
;
...
...
@@ -216,7 +219,7 @@ fn hash(u: &uint) -> uint {
i
=
0u
;
while
i
<
num_to_insert
{
assert
(
hm
.insert
(
i
,
i
*
i
));
log
"inserting "
+
uint
::
to_str
(
i
,
10u
)
+
" -> "
+
log
~
"inserting "
+
uint
::
to_str
(
i
,
10u
)
+
~
" -> "
+
uint
::
to_str
(
i
*
i
,
10u
);
i
+=
2u
;
}
...
...
@@ -224,7 +227,7 @@ fn hash(u: &uint) -> uint {
log
"-----"
;
i
=
0u
;
while
i
<
num_to_insert
{
log
"get("
+
uint
::
to_str
(
i
,
10u
)
+
") = "
+
log
~
"get("
+
uint
::
to_str
(
i
,
10u
)
+
~
") = "
+
uint
::
to_str
(
hm
.get
(
i
),
10u
);
assert
(
hm
.get
(
i
)
==
i
*
i
);
i
+=
1u
;
...
...
@@ -236,7 +239,7 @@ fn hash(u: &uint) -> uint {
assert
(
hm
.size
()
==
num_to_insert
);
i
=
0u
;
while
i
<
num_to_insert
{
log
"get("
+
uint
::
to_str
(
i
,
10u
)
+
") = "
+
log
~
"get("
+
uint
::
to_str
(
i
,
10u
)
+
~
") = "
+
uint
::
to_str
(
hm
.get
(
i
),
10u
);
assert
(
hm
.get
(
i
)
==
i
*
i
);
i
+=
1u
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录