Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
d507d5fe
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,发现更多精彩内容 >>
提交
d507d5fe
编写于
6月 24, 2011
作者:
M
Marijn Haverbeke
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove res idents from stdlib
上级
3d7fdb50
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
40 addition
and
40 deletion
+40
-40
src/lib/bitv.rs
src/lib/bitv.rs
+3
-3
src/lib/extfmt.rs
src/lib/extfmt.rs
+5
-5
src/lib/list.rs
src/lib/list.rs
+1
-1
src/lib/sha1.rs
src/lib/sha1.rs
+3
-3
src/lib/sort.rs
src/lib/sort.rs
+6
-6
src/lib/str.rs
src/lib/str.rs
+4
-4
src/lib/vec.rs
src/lib/vec.rs
+18
-18
未找到文件。
src/lib/bitv.rs
浏览文件 @
d507d5fe
...
@@ -154,11 +154,11 @@ fn to_vec(&t v) -> vec[uint] {
...
@@ -154,11 +154,11 @@ fn to_vec(&t v) -> vec[uint] {
}
}
fn
to_str
(
&
t
v
)
->
str
{
fn
to_str
(
&
t
v
)
->
str
{
auto
r
e
s
=
""
;
auto
rs
=
""
;
for
(
uint
i
in
bitv
::
to_vec
(
v
))
{
for
(
uint
i
in
bitv
::
to_vec
(
v
))
{
if
(
i
==
1u
)
{
r
es
+=
"1"
;
}
else
{
re
s
+=
"0"
;
}
if
(
i
==
1u
)
{
r
s
+=
"1"
;
}
else
{
r
s
+=
"0"
;
}
}
}
ret
r
e
s
;
ret
rs
;
}
}
...
...
src/lib/extfmt.rs
浏览文件 @
d507d5fe
...
@@ -95,9 +95,9 @@ fn flush_buf(str buf, &mutable vec[piece] pieces) -> str {
...
@@ -95,9 +95,9 @@ fn flush_buf(str buf, &mutable vec[piece] pieces) -> str {
i
+=
1u
;
i
+=
1u
;
}
else
{
}
else
{
buf
=
flush_buf
(
buf
,
pieces
);
buf
=
flush_buf
(
buf
,
pieces
);
auto
r
e
s
=
parse_conversion
(
s
,
i
,
lim
,
error
);
auto
rs
=
parse_conversion
(
s
,
i
,
lim
,
error
);
pieces
+=
[
r
e
s
._0
];
pieces
+=
[
rs
._0
];
i
=
r
e
s
._1
;
i
=
rs
._1
;
}
}
}
else
{
buf
+=
curr
;
i
+=
1u
;
}
}
else
{
buf
+=
curr
;
i
+=
1u
;
}
}
}
...
@@ -273,7 +273,7 @@ fn conv_int(&conv cv, int i) -> str {
...
@@ -273,7 +273,7 @@ fn conv_int(&conv cv, int i) -> str {
}
}
fn
conv_uint
(
&
conv
cv
,
uint
u
)
->
str
{
fn
conv_uint
(
&
conv
cv
,
uint
u
)
->
str
{
auto
prec
=
get_int_precision
(
cv
);
auto
prec
=
get_int_precision
(
cv
);
auto
r
e
s
=
auto
rs
=
alt
(
cv
.ty
)
{
alt
(
cv
.ty
)
{
case
(
ty_default
)
{
uint_to_str_prec
(
u
,
10u
,
prec
)
}
case
(
ty_default
)
{
uint_to_str_prec
(
u
,
10u
,
prec
)
}
case
(
ty_hex_lower
)
{
uint_to_str_prec
(
u
,
16u
,
prec
)
}
case
(
ty_hex_lower
)
{
uint_to_str_prec
(
u
,
16u
,
prec
)
}
...
@@ -283,7 +283,7 @@ fn conv_uint(&conv cv, uint u) -> str {
...
@@ -283,7 +283,7 @@ fn conv_uint(&conv cv, uint u) -> str {
case
(
ty_bits
)
{
uint_to_str_prec
(
u
,
2u
,
prec
)
}
case
(
ty_bits
)
{
uint_to_str_prec
(
u
,
2u
,
prec
)
}
case
(
ty_octal
)
{
uint_to_str_prec
(
u
,
8u
,
prec
)
}
case
(
ty_octal
)
{
uint_to_str_prec
(
u
,
8u
,
prec
)
}
};
};
ret
pad
(
cv
,
r
e
s
,
pad_unsigned
);
ret
pad
(
cv
,
rs
,
pad_unsigned
);
}
}
fn
conv_bool
(
&
conv
cv
,
bool
b
)
->
str
{
fn
conv_bool
(
&
conv
cv
,
bool
b
)
->
str
{
auto
s
=
if
(
b
)
{
"true"
}
else
{
"false"
};
auto
s
=
if
(
b
)
{
"true"
}
else
{
"false"
};
...
...
src/lib/list.rs
浏览文件 @
d507d5fe
...
@@ -37,7 +37,7 @@ fn find[T, U](&list[T] ls_, fn(&T) -> option::t[U] f) -> option::t[U] {
...
@@ -37,7 +37,7 @@ fn find[T, U](&list[T] ls_, fn(&T) -> option::t[U] f) -> option::t[U] {
case
(
cons
(
?
hd
,
?
tl
))
{
case
(
cons
(
?
hd
,
?
tl
))
{
alt
(
f
(
hd
))
{
alt
(
f
(
hd
))
{
case
(
none
)
{
ls
=
*
tl
;
}
case
(
none
)
{
ls
=
*
tl
;
}
case
(
some
(
?
r
es
))
{
ret
some
(
re
s
);
}
case
(
some
(
?
r
s
))
{
ret
some
(
r
s
);
}
}
}
}
}
case
(
nil
)
{
break
;
}
case
(
nil
)
{
break
;
}
...
...
src/lib/sha1.rs
浏览文件 @
d507d5fe
...
@@ -162,15 +162,15 @@ fn circular_shift(u32 bits, u32 word) -> u32 {
...
@@ -162,15 +162,15 @@ fn circular_shift(u32 bits, u32 word) -> u32 {
}
}
fn
mk_result
(
&
sha1state
st
)
->
vec
[
u8
]
{
fn
mk_result
(
&
sha1state
st
)
->
vec
[
u8
]
{
if
(
!
st
.computed
)
{
pad_msg
(
st
);
st
.computed
=
true
;
}
if
(
!
st
.computed
)
{
pad_msg
(
st
);
st
.computed
=
true
;
}
let
vec
[
u8
]
r
e
s
=
[];
let
vec
[
u8
]
rs
=
[];
for
(
u32
hpart
in
st
.h
)
{
for
(
u32
hpart
in
st
.h
)
{
auto
a
=
hpart
>>
24u32
&
0xFFu32
as
u8
;
auto
a
=
hpart
>>
24u32
&
0xFFu32
as
u8
;
auto
b
=
hpart
>>
16u32
&
0xFFu32
as
u8
;
auto
b
=
hpart
>>
16u32
&
0xFFu32
as
u8
;
auto
c
=
hpart
>>
8u32
&
0xFFu32
as
u8
;
auto
c
=
hpart
>>
8u32
&
0xFFu32
as
u8
;
auto
d
=
hpart
&
0xFFu32
as
u8
;
auto
d
=
hpart
&
0xFFu32
as
u8
;
r
e
s
+=
[
a
,
b
,
c
,
d
];
rs
+=
[
a
,
b
,
c
,
d
];
}
}
ret
r
e
s
;
ret
rs
;
}
}
/*
/*
* According to the standard, the message must be padded to an even
* According to the standard, the message must be padded to an even
...
...
src/lib/sort.rs
浏览文件 @
d507d5fe
...
@@ -10,20 +10,20 @@
...
@@ -10,20 +10,20 @@
fn
merge_sort
[
T
](
lteq
[
T
]
le
,
vec
[
T
]
v
)
->
vec
[
T
]
{
fn
merge_sort
[
T
](
lteq
[
T
]
le
,
vec
[
T
]
v
)
->
vec
[
T
]
{
fn
merge
[
T
](
lteq
[
T
]
le
,
vec
[
T
]
a
,
vec
[
T
]
b
)
->
vec
[
T
]
{
fn
merge
[
T
](
lteq
[
T
]
le
,
vec
[
T
]
a
,
vec
[
T
]
b
)
->
vec
[
T
]
{
let
vec
[
T
]
r
e
s
=
[];
let
vec
[
T
]
rs
=
[];
let
uint
a_len
=
len
[
T
](
a
);
let
uint
a_len
=
len
[
T
](
a
);
let
uint
a_ix
=
0u
;
let
uint
a_ix
=
0u
;
let
uint
b_len
=
len
[
T
](
b
);
let
uint
b_len
=
len
[
T
](
b
);
let
uint
b_ix
=
0u
;
let
uint
b_ix
=
0u
;
while
(
a_ix
<
a_len
&&
b_ix
<
b_len
)
{
while
(
a_ix
<
a_len
&&
b_ix
<
b_len
)
{
if
(
le
(
a
.
(
a_ix
),
b
.
(
b_ix
)))
{
if
(
le
(
a
.
(
a_ix
),
b
.
(
b_ix
)))
{
r
e
s
+=
[
a
.
(
a_ix
)];
rs
+=
[
a
.
(
a_ix
)];
a_ix
+=
1u
;
a_ix
+=
1u
;
}
else
{
r
e
s
+=
[
b
.
(
b_ix
)];
b_ix
+=
1u
;
}
}
else
{
rs
+=
[
b
.
(
b_ix
)];
b_ix
+=
1u
;
}
}
}
r
e
s
+=
slice
[
T
](
a
,
a_ix
,
a_len
);
rs
+=
slice
[
T
](
a
,
a_ix
,
a_len
);
r
e
s
+=
slice
[
T
](
b
,
b_ix
,
b_len
);
rs
+=
slice
[
T
](
b
,
b_ix
,
b_len
);
ret
r
e
s
;
ret
rs
;
}
}
let
uint
v_len
=
len
[
T
](
v
);
let
uint
v_len
=
len
[
T
](
v
);
if
(
v_len
<=
1u
)
{
ret
v
;
}
if
(
v_len
<=
1u
)
{
ret
v
;
}
...
...
src/lib/str.rs
浏览文件 @
d507d5fe
...
@@ -410,10 +410,10 @@ fn push_byte(&mutable str s, u8 b) {
...
@@ -410,10 +410,10 @@ fn push_byte(&mutable str s, u8 b) {
}
}
fn
unshift_byte
(
&
mutable
str
s
,
u8
b
)
{
fn
unshift_byte
(
&
mutable
str
s
,
u8
b
)
{
auto
r
e
s
=
alloc
(
byte_len
(
s
)
+
1u
);
auto
rs
=
alloc
(
byte_len
(
s
)
+
1u
);
r
e
s
+=
unsafe_from_byte
(
b
);
rs
+=
unsafe_from_byte
(
b
);
r
e
s
+=
s
;
rs
+=
s
;
s
=
r
e
s
;
s
=
rs
;
}
}
fn
split
(
str
s
,
u8
sep
)
->
vec
[
str
]
{
fn
split
(
str
s
,
u8
sep
)
->
vec
[
str
]
{
...
...
src/lib/vec.rs
浏览文件 @
d507d5fe
...
@@ -172,10 +172,10 @@ fn top[T](&array[T] v) -> T {
...
@@ -172,10 +172,10 @@ fn top[T](&array[T] v) -> T {
fn
push
[
T
](
&
mutable
array
[
T
]
v
,
&
T
t
)
{
v
+=
[
t
];
}
fn
push
[
T
](
&
mutable
array
[
T
]
v
,
&
T
t
)
{
v
+=
[
t
];
}
fn
unshift
[
T
](
&
mutable
array
[
T
]
v
,
&
T
t
)
{
fn
unshift
[
T
](
&
mutable
array
[
T
]
v
,
&
T
t
)
{
auto
r
e
s
=
alloc
[
T
](
len
[
T
](
v
)
+
1u
);
auto
rs
=
alloc
[
T
](
len
[
T
](
v
)
+
1u
);
r
e
s
+=
[
t
];
rs
+=
[
t
];
r
e
s
+=
v
;
rs
+=
v
;
v
=
r
e
s
;
v
=
rs
;
}
}
fn
grow
[
T
](
&
mutable
array
[
T
]
v
,
uint
n
,
&
T
initval
)
{
fn
grow
[
T
](
&
mutable
array
[
T
]
v
,
uint
n
,
&
T
initval
)
{
...
@@ -201,17 +201,17 @@ fn grow_init_fn_set[T](&array[T] v, uint index, fn() -> T init_fn, &T val) {
...
@@ -201,17 +201,17 @@ fn grow_init_fn_set[T](&array[T] v, uint index, fn() -> T init_fn, &T val) {
}
}
fn
map
[
T
,
U
](
&
fn
(
&
T
)
->
U
f
,
&
vec
[
T
]
v
)
->
vec
[
U
]
{
fn
map
[
T
,
U
](
&
fn
(
&
T
)
->
U
f
,
&
vec
[
T
]
v
)
->
vec
[
U
]
{
let
vec
[
U
]
r
e
s
=
alloc
[
U
](
len
[
T
](
v
));
let
vec
[
U
]
rs
=
alloc
[
U
](
len
[
T
](
v
));
for
(
T
ve
in
v
)
{
r
e
s
+=
[
f
(
ve
)];
}
for
(
T
ve
in
v
)
{
rs
+=
[
f
(
ve
)];
}
ret
r
e
s
;
ret
rs
;
}
}
fn
filter_map
[
T
,
U
](
&
fn
(
&
T
)
->
option
::
t
[
U
]
f
,
&
vec
[
T
]
v
)
->
vec
[
U
]
{
fn
filter_map
[
T
,
U
](
&
fn
(
&
T
)
->
option
::
t
[
U
]
f
,
&
vec
[
T
]
v
)
->
vec
[
U
]
{
let
vec
[
U
]
r
e
s
=
[];
let
vec
[
U
]
rs
=
[];
for
(
T
ve
in
v
)
{
for
(
T
ve
in
v
)
{
alt
(
f
(
ve
))
{
case
(
some
(
?
elt
))
{
r
e
s
+=
[
elt
];
}
case
(
none
)
{
}
}
alt
(
f
(
ve
))
{
case
(
some
(
?
elt
))
{
rs
+=
[
elt
];
}
case
(
none
)
{
}
}
}
}
ret
r
e
s
;
ret
rs
;
}
}
fn
map2
[
T
,
U
,
V
](
&
operator2
[
T
,
U
,
V
]
f
,
&
vec
[
T
]
v0
,
&
vec
[
U
]
v1
)
->
vec
[
V
]
{
fn
map2
[
T
,
U
,
V
](
&
operator2
[
T
,
U
,
V
]
f
,
&
vec
[
T
]
v0
,
&
vec
[
U
]
v1
)
->
vec
[
V
]
{
...
@@ -288,11 +288,11 @@ fn plus_option[T](&mutable vec[T] v, &option::t[T] o) {
...
@@ -288,11 +288,11 @@ fn plus_option[T](&mutable vec[T] v, &option::t[T] o) {
}
}
fn
cat_options
[
T
](
&
vec
[
option
::
t
[
T
]]
v
)
->
vec
[
T
]
{
fn
cat_options
[
T
](
&
vec
[
option
::
t
[
T
]]
v
)
->
vec
[
T
]
{
let
vec
[
T
]
r
e
s
=
[];
let
vec
[
T
]
rs
=
[];
for
(
option
::
t
[
T
]
o
in
v
)
{
for
(
option
::
t
[
T
]
o
in
v
)
{
alt
(
o
)
{
case
(
none
)
{
}
case
(
some
(
?
t
))
{
r
e
s
+=
[
t
];
}
}
alt
(
o
)
{
case
(
none
)
{
}
case
(
some
(
?
t
))
{
rs
+=
[
t
];
}
}
}
}
ret
r
e
s
;
ret
rs
;
}
}
...
@@ -322,12 +322,12 @@ fn reverse[T](&vec[mutable T] v) {
...
@@ -322,12 +322,12 @@ fn reverse[T](&vec[mutable T] v) {
// Functional vector reversal. Returns a reversed copy of v.
// Functional vector reversal. Returns a reversed copy of v.
fn
reversed
[
T
](
vec
[
T
]
v
)
->
vec
[
T
]
{
fn
reversed
[
T
](
vec
[
T
]
v
)
->
vec
[
T
]
{
let
vec
[
T
]
r
e
s
=
[];
let
vec
[
T
]
rs
=
[];
auto
i
=
len
[
T
](
v
);
auto
i
=
len
[
T
](
v
);
if
(
i
==
0u
)
{
ret
r
e
s
;
}
else
{
i
-=
1u
;
}
if
(
i
==
0u
)
{
ret
rs
;
}
else
{
i
-=
1u
;
}
while
(
i
!=
0u
)
{
push
[
T
](
r
e
s
,
v
.
(
i
));
i
-=
1u
;
}
while
(
i
!=
0u
)
{
push
[
T
](
rs
,
v
.
(
i
));
i
-=
1u
;
}
push
[
T
](
r
e
s
,
v
.
(
0
));
push
[
T
](
rs
,
v
.
(
0
));
ret
r
e
s
;
ret
rs
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录