Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
53be480d
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,发现更多精彩内容 >>
提交
53be480d
编写于
8月 23, 2011
作者:
B
Brian Anderson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Convert std::int to istrs. Issue #855
上级
ee2a11eb
变更
20
隐藏空白更改
内联
并排
Showing
20 changed file
with
92 addition
and
51 deletion
+92
-51
src/comp/driver/rustc.rs
src/comp/driver/rustc.rs
+7
-4
src/comp/lib/llvm.rs
src/comp/lib/llvm.rs
+4
-2
src/comp/metadata/tyencode.rs
src/comp/metadata/tyencode.rs
+4
-1
src/comp/middle/freevars.rs
src/comp/middle/freevars.rs
+5
-1
src/comp/middle/trans_common.rs
src/comp/middle/trans_common.rs
+3
-1
src/comp/middle/tstate/annotate.rs
src/comp/middle/tstate/annotate.rs
+3
-3
src/comp/middle/tstate/auxiliary.rs
src/comp/middle/tstate/auxiliary.rs
+9
-5
src/comp/middle/ty.rs
src/comp/middle/ty.rs
+3
-2
src/comp/middle/typeck.rs
src/comp/middle/typeck.rs
+8
-3
src/comp/syntax/ext/fmt.rs
src/comp/syntax/ext/fmt.rs
+13
-5
src/comp/syntax/parse/token.rs
src/comp/syntax/parse/token.rs
+3
-3
src/comp/syntax/print/pprust.rs
src/comp/syntax/print/pprust.rs
+2
-2
src/comp/util/ppaux.rs
src/comp/util/ppaux.rs
+6
-2
src/lib/int.rs
src/lib/int.rs
+4
-4
src/lib/io.rs
src/lib/io.rs
+2
-1
src/test/bench/99bob-iter.rs
src/test/bench/99bob-iter.rs
+2
-1
src/test/bench/99bob-pattern.rs
src/test/bench/99bob-pattern.rs
+3
-2
src/test/bench/99bob-simple.rs
src/test/bench/99bob-simple.rs
+2
-1
src/test/bench/99bob-tail.rs
src/test/bench/99bob-tail.rs
+3
-2
src/test/stdtest/int.rs
src/test/stdtest/int.rs
+6
-6
未找到文件。
src/comp/driver/rustc.rs
浏览文件 @
53be480d
...
...
@@ -27,6 +27,7 @@
import
std
::
option
::
some
;
import
std
::
option
::
none
;
import
std
::
str
;
import
std
::
istr
;
import
std
::
vec
;
import
std
::
int
;
import
std
::
io
;
...
...
@@ -189,16 +190,18 @@ fn ann_identified_post(node: &pprust::ann_node) {
alt
node
{
pprust
::
node_item
(
s
,
item
)
{
pp
::
space
(
s
.s
);
pprust
::
synth_comment
(
s
,
int
::
to_str
(
item
.id
,
10u
));
pprust
::
synth_comment
(
s
,
istr
::
to_estr
(
int
::
to_str
(
item
.id
,
10u
)));
}
pprust
::
node_block
(
s
,
blk
)
{
pp
::
space
(
s
.s
);
pprust
::
synth_comment
(
s
,
"block "
+
int
::
to_str
(
blk
.node.id
,
10u
));
pprust
::
synth_comment
(
s
,
istr
::
to_estr
(
~
"block "
+
int
::
to_str
(
blk
.node.id
,
10u
)
));
}
pprust
::
node_expr
(
s
,
expr
)
{
pp
::
space
(
s
.s
);
pprust
::
synth_comment
(
s
,
int
::
to_str
(
expr
.id
,
10u
));
pprust
::
synth_comment
(
s
,
istr
::
to_estr
(
int
::
to_str
(
expr
.id
,
10u
)));
pprust
::
pclose
(
s
);
}
_
{
}
...
...
src/comp/lib/llvm.rs
浏览文件 @
53be480d
import
std
::
vec
;
import
std
::
str
;
import
std
::
istr
;
import
std
::
str
::
rustrt
::
sbuf
;
import
llvm
::
ModuleRef
;
...
...
@@ -976,7 +977,8 @@ fn tys_str(names: type_names, outer: &[TypeRef], tys: &[TypeRef]) -> str {
7
{
ret
"i"
+
std
::
int
::
str
(
llvm
::
LLVMGetIntTypeWidth
(
ty
)
as
int
);
ret
"i"
+
istr
::
to_estr
(
std
::
int
::
str
(
llvm
::
LLVMGetIntTypeWidth
(
ty
)
as
int
));
}
...
...
@@ -1020,7 +1022,7 @@ fn tys_str(names: type_names, outer: &[TypeRef], tys: &[TypeRef]) -> str {
i
+=
1u
;
if
tout
as
int
==
ty
as
int
{
let
n
:
uint
=
vec
::
len
::
<
TypeRef
>
(
outer0
)
-
i
;
ret
"*
\\
"
+
std
::
int
::
str
(
n
as
int
);
ret
"*
\\
"
+
istr
::
to_estr
(
std
::
int
::
str
(
n
as
int
)
);
}
}
ret
"*"
+
...
...
src/comp/metadata/tyencode.rs
浏览文件 @
53be480d
...
...
@@ -172,7 +172,10 @@ fn enc_sty(w: &io::writer, cx: &@ctxt, st: &ty::sty) {
for
t
:
ty
::
t
in
tps
{
enc_ty
(
w
,
cx
,
t
);
}
w
.write_char
(
']'
);
}
ty
::
ty_var
(
id
)
{
w
.write_char
(
'X'
);
w
.write_str
(
int
::
str
(
id
));
}
ty
::
ty_var
(
id
)
{
w
.write_char
(
'X'
);
w
.write_str
(
istr
::
to_estr
(
int
::
str
(
id
)));
}
ty
::
ty_native
(
def
)
{
w
.write_char
(
'E'
);
w
.write_str
(
cx
.ds
(
def
));
...
...
src/comp/middle/freevars.rs
浏览文件 @
53be480d
...
...
@@ -5,6 +5,7 @@
import
std
::
map
::
*
;
import
std
::
option
;
import
std
::
int
;
import
std
::
istr
;
import
std
::
option
::
*
;
import
syntax
::
ast
;
import
syntax
::
ast_util
;
...
...
@@ -146,7 +147,10 @@ fn annotate_freevars(sess: &session::session, def_map: &resolve::def_map,
fn
get_freevar_info
(
tcx
:
&
ty
::
ctxt
,
fid
:
ast
::
node_id
)
->
freevar_info
{
alt
tcx
.freevars
.find
(
fid
)
{
none
.
{
fail
"get_freevars: "
+
int
::
str
(
fid
)
+
" has no freevars"
;
}
none
.
{
fail
"get_freevars: "
+
istr
::
to_estr
(
int
::
str
(
fid
))
+
" has no freevars"
;
}
some
(
d
)
{
ret
d
;
}
}
}
...
...
src/comp/middle/trans_common.rs
浏览文件 @
53be480d
...
...
@@ -63,7 +63,9 @@
import
trans
::
drop_ty
;
obj
namegen
(
mutable
i
:
int
)
{
fn
next
(
prefix
:
str
)
->
str
{
i
+=
1
;
ret
prefix
+
int
::
str
(
i
);
}
fn
next
(
prefix
:
str
)
->
str
{
i
+=
1
;
ret
prefix
+
istr
::
to_estr
(
int
::
str
(
i
));
}
}
type
derived_tydesc_info
=
{
lltydesc
:
ValueRef
,
escapes
:
bool
};
...
...
src/comp/middle/tstate/annotate.rs
浏览文件 @
53be480d
...
...
@@ -32,12 +32,12 @@
fn
collect_ids_stmt
(
s
:
&@
stmt
,
rs
:
@
mutable
[
node_id
])
{
alt
s
.node
{
stmt_decl
(
_
,
id
)
{
log
"node_id "
+
int
::
str
(
id
);
log
~
"node_id "
+
int
::
str
(
id
);
log_stmt
(
*
s
);;
*
rs
+=
[
id
];
}
stmt_expr
(
_
,
id
)
{
log
"node_id "
+
int
::
str
(
id
);
log
~
"node_id "
+
int
::
str
(
id
);
log_stmt
(
*
s
);;
*
rs
+=
[
id
];
}
...
...
@@ -62,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
i
nt
::
str
(
i
)
+
" |-> "
+
istr
::
to_estr
(
uint
::
str
(
len
));
log
i
str
::
to_estr
(
int
::
str
(
i
)
+
~
" |-> "
+
uint
::
str
(
len
));
add_node
(
ccx
,
i
,
empty_ann
(
len
));
}
}
...
...
src/comp/middle/tstate/auxiliary.rs
浏览文件 @
53be480d
...
...
@@ -57,7 +57,7 @@
/* logging funs */
fn
def_id_to_str
(
d
:
def_id
)
->
str
{
ret
i
nt
::
str
(
d
.crate
)
+
","
+
int
::
str
(
d
.node
);
ret
i
str
::
to_estr
(
int
::
str
(
d
.crate
)
+
~
","
+
int
::
str
(
d
.node
)
);
}
fn
comma_str
(
args
:
&
[
@
constr_arg_use
])
->
str
{
...
...
@@ -329,7 +329,8 @@ fn get_ts_ann(ccx: &crate_ctxt, i: node_id) -> option::t<ts_ann> {
fn
node_id_to_ts_ann
(
ccx
:
&
crate_ctxt
,
id
:
node_id
)
->
ts_ann
{
alt
get_ts_ann
(
ccx
,
id
)
{
none
.
{
log_err
"node_id_to_ts_ann: no ts_ann for node_id "
+
int
::
str
(
id
);
log_err
"node_id_to_ts_ann: no ts_ann for node_id "
+
istr
::
to_estr
(
int
::
str
(
id
));
fail
;
}
some
(
t
)
{
ret
t
;
}
...
...
@@ -531,7 +532,8 @@ fn constraints_expr(cx: &ty::ctxt, e: @expr) -> [@ty::constr] {
fn
node_id_to_def_upvar_strict
(
cx
:
&
fn_ctxt
,
id
:
node_id
)
->
def
{
alt
freevars
::
def_lookup
(
cx
.ccx.tcx
,
cx
.id
,
id
)
{
none
.
{
log_err
"node_id_to_def: node_id "
+
int
::
str
(
id
)
+
" has no def"
;
log_err
"node_id_to_def: node_id "
+
istr
::
to_estr
(
int
::
str
(
id
))
+
" has no def"
;
fail
;
}
some
(
d
)
{
ret
d
;
}
...
...
@@ -540,7 +542,8 @@ fn node_id_to_def_upvar_strict(cx: &fn_ctxt, id: node_id) -> def {
fn
node_id_to_def_strict
(
cx
:
&
ty
::
ctxt
,
id
:
node_id
)
->
def
{
alt
cx
.def_map
.find
(
id
)
{
none
.
{
log_err
"node_id_to_def: node_id "
+
int
::
str
(
id
)
+
" has no def"
;
log_err
"node_id_to_def: node_id "
+
istr
::
to_estr
(
int
::
str
(
id
))
+
" has no def"
;
fail
;
}
some
(
d
)
{
ret
d
;
}
...
...
@@ -601,7 +604,8 @@ fn match_args(fcx: &fn_ctxt, occs: &@mutable [pred_args],
fn
def_id_for_constr
(
tcx
:
ty
::
ctxt
,
t
:
node_id
)
->
def_id
{
alt
tcx
.def_map
.find
(
t
)
{
none
.
{
tcx
.sess
.bug
(
"node_id_for_constr: bad node_id "
+
int
::
str
(
t
));
tcx
.sess
.bug
(
"node_id_for_constr: bad node_id "
+
istr
::
to_estr
(
int
::
str
(
t
)));
}
some
(
def_fn
(
i
,
_
))
{
ret
i
;
}
_
{
tcx
.sess
.bug
(
"node_id_for_constr: pred is not a function"
);
}
...
...
src/comp/middle/ty.rs
浏览文件 @
53be480d
...
...
@@ -1629,8 +1629,9 @@ fn node_id_to_ty_param_substs_opt_and_ty(cx: &ctxt, id: &ast::node_id) ->
alt
smallintmap
::
find
(
*
cx
.node_types
,
id
as
uint
)
{
none
.
{
cx
.sess
.bug
(
"node_id_to_ty_param_substs_opt_and_ty() called on "
+
"an untyped node ("
+
std
::
int
::
to_str
(
id
,
10u
)
+
")"
);
"an untyped node ("
+
istr
::
to_estr
(
std
::
int
::
to_str
(
id
,
10u
))
+
")"
);
}
some
(
tpot
)
{
ret
tpot
;
}
}
...
...
src/comp/middle/typeck.rs
浏览文件 @
53be480d
...
...
@@ -37,6 +37,7 @@
import
std
::
int
;
import
std
::
vec
;
import
std
::
str
;
import
std
::
istr
;
import
std
::
uint
;
import
std
::
map
;
import
std
::
map
::
hashmap
;
...
...
@@ -586,7 +587,10 @@ fn getter(cx: @ctxt, id: &ast::def_id) -> ty::ty_param_kinds_and_ty {
some
(
ast_map
::
node_native_item
(
native_item
))
{
tpt
=
ty_of_native_item
(
cx
,
native_item
,
ast
::
native_abi_cdecl
);
}
_
{
cx
.tcx.sess
.fatal
(
"internal error "
+
std
::
int
::
str
(
id
.node
));
}
_
{
cx
.tcx.sess
.fatal
(
"internal error "
+
istr
::
to_estr
(
std
::
int
::
str
(
id
.node
)));
}
}
ret
tpt
;
}
...
...
@@ -2152,8 +2156,9 @@ fn check_binop_type_compat(fcx: &@fn_ctxt, span: span, ty: ty::t,
this_obj_sty
=
some
(
structure_of
(
fcx
,
expr
.span
,
tpt
.ty
));
}
none
.
{
tcx
.sess
.bug
(
"didn't find "
+
int
::
str
(
did
.node
)
+
" in type cache"
);
tcx
.sess
.bug
(
"didn't find "
+
istr
::
to_estr
(
int
::
str
(
did
.node
))
+
" in type cache"
);
}
}
}
...
...
src/comp/syntax/ext/fmt.rs
浏览文件 @
53be480d
...
...
@@ -7,6 +7,7 @@
*/
import
std
::
vec
;
import
std
::
str
;
import
std
::
istr
;
import
std
::
option
;
import
std
::
option
::
none
;
import
std
::
option
::
some
;
...
...
@@ -258,7 +259,10 @@ fn is_signed_type(cnv: conv) -> bool {
}
fn
log_conv
(
c
:
conv
)
{
alt
c
.param
{
some
(
p
)
{
log
"param: "
+
std
::
int
::
to_str
(
p
,
10u
);
}
some
(
p
)
{
log
"param: "
+
istr
::
to_estr
(
std
::
int
::
to_str
(
p
,
10u
));
}
_
{
log
"param: none"
;
}
}
for
f
:
flag
in
c
.flags
{
...
...
@@ -271,17 +275,21 @@ fn log_conv(c: conv) {
}
}
alt
c
.width
{
count_is
(
i
)
{
log
"width: count is "
+
std
::
int
::
to_str
(
i
,
10u
);
}
count_is
(
i
)
{
log
"width: count is "
+
istr
::
to_estr
(
std
::
int
::
to_str
(
i
,
10u
));
}
count_is_param
(
i
)
{
log
"width: count is param "
+
std
::
int
::
to_str
(
i
,
10u
);
log
"width: count is param "
+
istr
::
to_estr
(
std
::
int
::
to_str
(
i
,
10u
));
}
count_is_next_param
.
{
log
"width: count is next param"
;
}
count_implied
.
{
log
"width: count is implied"
;
}
}
alt
c
.precision
{
count_is
(
i
)
{
log
"prec: count is "
+
std
::
int
::
to_str
(
i
,
10u
);
}
count_is
(
i
)
{
log
"prec: count is "
+
istr
::
to_estr
(
std
::
int
::
to_str
(
i
,
10u
));
}
count_is_param
(
i
)
{
log
"prec: count is param "
+
std
::
int
::
to_str
(
i
,
10u
);
log
"prec: count is param "
+
istr
::
to_estr
(
std
::
int
::
to_str
(
i
,
10u
));
}
count_is_next_param
.
{
log
"prec: count is next param"
;
}
count_implied
.
{
log
"prec: count is implied"
;
}
...
...
src/comp/syntax/parse/token.rs
浏览文件 @
53be480d
...
...
@@ -145,11 +145,11 @@ fn to_str(r: lexer::reader, t: token) -> str {
/* Literals */
LIT_INT
(
i
)
{
ret
i
nt
::
to_str
(
i
,
10u
);
ret
i
str
::
to_estr
(
int
::
to_str
(
i
,
10u
)
);
}
LIT_UINT
(
u
)
{
ret
istr
::
to_estr
(
uint
::
to_str
(
u
,
10u
));
}
LIT_MACH_INT
(
tm
,
i
)
{
ret
i
nt
::
to_str
(
i
,
10u
)
+
"_"
+
ty_mach_to_str
(
tm
);
ret
i
str
::
to_estr
(
int
::
to_str
(
i
,
10u
)
)
+
"_"
+
ty_mach_to_str
(
tm
);
}
LIT_MACH_FLOAT
(
tm
,
s
)
{
ret
interner
::
get
::
<
str
>
(
*
r
.get_interner
(),
s
)
+
"_"
+
...
...
@@ -173,7 +173,7 @@ fn to_str(r: lexer::reader, t: token) -> str {
IDENT
(
s
,
_
)
{
ret
interner
::
get
::
<
str
>
(
*
r
.get_interner
(),
s
);
}
IDX
(
i
)
{
ret
"_"
+
int
::
to_str
(
i
,
10u
);
}
IDX
(
i
)
{
ret
istr
::
to_estr
(
~
"_"
+
int
::
to_str
(
i
,
10u
)
);
}
UNDERSCORE
.
{
ret
"_"
;
}
BRACEQUOTE
(
_
)
{
ret
"<bracequote>"
;
}
EOF
.
{
ret
"<eof>"
;
}
...
...
src/comp/syntax/print/pprust.rs
浏览文件 @
53be480d
...
...
@@ -1498,11 +1498,11 @@ fn print_literal(s: &ps, lit: &@ast::lit) {
"'"
+
escape_str
(
str
::
unsafe_from_bytes
([
ch
as
u8
]),
'\''
)
+
"'"
);
}
ast
::
lit_int
(
val
)
{
word
(
s
.s
,
i
nt
::
str
(
val
));
}
ast
::
lit_int
(
val
)
{
word
(
s
.s
,
i
str
::
to_estr
(
int
::
str
(
val
)
));
}
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
,
i
nt
::
str
(
val
as
int
));
word
(
s
.s
,
i
str
::
to_estr
(
int
::
str
(
val
as
int
)
));
word
(
s
.s
,
ast_util
::
ty_mach_to_str
(
mach
));
}
ast
::
lit_mach_float
(
mach
,
val
)
{
...
...
src/comp/util/ppaux.rs
浏览文件 @
53be480d
import
std
::
vec
;
import
std
::
str
;
import
std
::
istr
;
import
std
::
int
;
import
std
::
option
;
import
std
::
option
::
none
;
...
...
@@ -35,7 +36,10 @@ fn mode_str_1(m: &ty::mode) -> str {
}
fn
fn_ident_to_string
(
id
:
ast
::
node_id
,
i
:
&
ast
::
fn_ident
)
->
str
{
ret
alt
i
{
none
.
{
"anon"
+
int
::
str
(
id
)
}
some
(
s
)
{
s
}
};
ret
alt
i
{
none
.
{
istr
::
to_estr
(
~
"anon"
+
int
::
str
(
id
))
}
some
(
s
)
{
s
}
};
}
fn
get_id_ident
(
cx
:
&
ctxt
,
id
:
ast
::
def_id
)
->
str
{
...
...
@@ -139,7 +143,7 @@ fn mt_to_str(cx: &ctxt, m: &mt) -> str {
"obj {
\n\t
"
+
str
::
connect
(
strs
,
"
\n\t
"
)
+
"
\n
}"
}
ty_res
(
id
,
_
,
_
)
{
get_id_ident
(
cx
,
id
)
}
ty_var
(
v
)
{
"<T"
+
int
::
str
(
v
)
+
">"
}
ty_var
(
v
)
{
istr
::
to_estr
(
~
"<T"
+
int
::
str
(
v
)
+
~
">"
)
}
ty_param
(
id
,
_
)
{
"'"
+
str
::
unsafe_from_bytes
([(
'a'
as
u8
)
+
(
id
as
u8
)])
}
...
...
src/lib/int.rs
浏览文件 @
53be480d
...
...
@@ -41,13 +41,13 @@
while
lo_
<
hi
{
put
lo_
;
lo_
+=
1
;
}
}
fn
to_str
(
n
:
int
,
radix
:
uint
)
->
str
{
fn
to_str
(
n
:
int
,
radix
:
uint
)
->
i
str
{
assert
(
0u
<
radix
&&
radix
<=
16u
);
ret
if
n
<
0
{
"-"
+
istr
::
to_estr
(
uint
::
to_str
(
-
n
as
uint
,
radix
)
)
}
else
{
istr
::
to_estr
(
uint
::
to_str
(
n
as
uint
,
radix
)
)
};
~
"-"
+
uint
::
to_str
(
-
n
as
uint
,
radix
)
}
else
{
uint
::
to_str
(
n
as
uint
,
radix
)
};
}
fn
str
(
i
:
int
)
->
str
{
ret
to_str
(
i
,
10u
);
}
fn
str
(
i
:
int
)
->
i
str
{
ret
to_str
(
i
,
10u
);
}
fn
pow
(
base
:
int
,
exponent
:
uint
)
->
int
{
ret
if
exponent
==
0u
{
...
...
src/lib/io.rs
浏览文件 @
53be480d
...
...
@@ -337,7 +337,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_int
(
n
:
int
)
{
out
.write
(
str
::
bytes
(
istr
::
to_estr
(
int
::
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
);
}
...
...
src/test/bench/99bob-iter.rs
浏览文件 @
53be480d
...
...
@@ -7,6 +7,7 @@
use
std
;
import
std
::
int
;
import
std
::
str
;
import
std
::
istr
;
fn
b1
()
->
str
{
ret
"# of beer on the wall, # of beer."
;
}
...
...
@@ -29,7 +30,7 @@ fn sub(t: str, n: int) -> str {
alt
n
{
0
{
ns
=
"no more bottles"
;
}
1
{
ns
=
"1 bottle"
;
}
_
{
ns
=
i
nt
::
to_str
(
n
,
10u
)
+
" bottles"
;
}
_
{
ns
=
i
str
::
to_estr
(
int
::
to_str
(
n
,
10u
)
+
~
" bottles"
)
;
}
}
while
i
<
str
::
byte_len
(
t
)
{
if
t
[
i
]
==
'#'
as
u8
{
b
+=
ns
;
}
else
{
str
::
push_byte
(
b
,
t
[
i
]);
}
...
...
src/test/bench/99bob-pattern.rs
浏览文件 @
53be480d
...
...
@@ -7,6 +7,7 @@
use
std
;
import
std
::
int
;
import
std
::
str
;
import
std
::
istr
;
tag
bottle
{
none
;
dual
;
single
;
multiple
(
int
);
}
...
...
@@ -29,8 +30,8 @@ fn show(b: bottle) {
"1 bottle of beer on the wall."
;
}
multiple
(
n
)
{
let
nb
:
str
=
i
nt
::
to_str
(
n
,
10u
);
let
mb
:
str
=
i
nt
::
to_str
(
n
-
1
,
10u
);
let
nb
:
str
=
i
str
::
to_estr
(
int
::
to_str
(
n
,
10u
)
);
let
mb
:
str
=
i
str
::
to_estr
(
int
::
to_str
(
n
-
1
,
10u
)
);
log
nb
+
" bottles of beer on the wall, "
+
nb
+
" bottles of beer,"
;
log
"Take one down and pass it around, "
+
mb
+
" bottles of beer on the wall."
;
...
...
src/test/bench/99bob-simple.rs
浏览文件 @
53be480d
...
...
@@ -7,6 +7,7 @@
use
std
;
import
std
::
int
;
import
std
::
str
;
import
std
::
istr
;
fn
b1
()
->
str
{
ret
"# of beer on the wall, # of beer."
;
}
...
...
@@ -29,7 +30,7 @@ fn sub(t: str, n: int) -> str {
alt
n
{
0
{
ns
=
"no more bottles"
;
}
1
{
ns
=
"1 bottle"
;
}
_
{
ns
=
i
nt
::
to_str
(
n
,
10u
)
+
" bottles"
;
}
_
{
ns
=
i
str
::
to_estr
(
int
::
to_str
(
n
,
10u
)
+
~
" bottles"
)
;
}
}
while
i
<
str
::
byte_len
(
t
)
{
if
t
[
i
]
==
'#'
as
u8
{
b
+=
ns
;
}
else
{
str
::
push_byte
(
b
,
t
[
i
]);
}
...
...
src/test/bench/99bob-tail.rs
浏览文件 @
53be480d
...
...
@@ -5,11 +5,12 @@
use
std
;
import
std
::
int
;
import
std
::
str
;
import
std
::
istr
;
fn
main
()
{
fn
multiple
(
n
:
int
)
{
let
nb
:
str
=
i
nt
::
to_str
(
n
,
10u
);
let
mb
:
str
=
i
nt
::
to_str
(
n
-
1
,
10u
);
let
nb
:
str
=
i
str
::
to_estr
(
int
::
to_str
(
n
,
10u
)
);
let
mb
:
str
=
i
str
::
to_estr
(
int
::
to_str
(
n
-
1
,
10u
)
);
log
nb
+
" bottles of beer on the wall, "
+
nb
+
" bottles of beer,"
;
log
"Take one down and pass it around, "
+
mb
+
" bottles of beer on the wall."
;
...
...
src/test/stdtest/int.rs
浏览文件 @
53be480d
use
std
;
import
std
::
int
;
import
std
::
str
::
eq
;
import
std
::
i
str
::
eq
;
#[test]
fn
test_to_str
()
{
assert
(
eq
(
int
::
to_str
(
0
,
10u
),
"0"
));
assert
(
eq
(
int
::
to_str
(
1
,
10u
),
"1"
));
assert
(
eq
(
int
::
to_str
(
-
1
,
10u
),
"-1"
));
assert
(
eq
(
int
::
to_str
(
255
,
16u
),
"ff"
));
assert
(
eq
(
int
::
to_str
(
100
,
10u
),
"100"
));
assert
(
eq
(
int
::
to_str
(
0
,
10u
),
~
"0"
));
assert
(
eq
(
int
::
to_str
(
1
,
10u
),
~
"1"
));
assert
(
eq
(
int
::
to_str
(
-
1
,
10u
),
~
"-1"
));
assert
(
eq
(
int
::
to_str
(
255
,
16u
),
~
"ff"
));
assert
(
eq
(
int
::
to_str
(
100
,
10u
),
~
"100"
));
}
#[test]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录