Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
49cb3fc7
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,发现更多精彩内容 >>
提交
49cb3fc7
编写于
2月 01, 2012
作者:
T
Tim Chevalier
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove remaining references to option::t outside option itself
上级
4eb92d41
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
12 addition
and
12 deletion
+12
-12
src/libcore/char.rs
src/libcore/char.rs
+1
-1
src/libcore/extfmt.rs
src/libcore/extfmt.rs
+3
-3
src/libcore/task.rs
src/libcore/task.rs
+1
-1
src/libcore/vec.rs
src/libcore/vec.rs
+7
-7
未找到文件。
src/libcore/char.rs
浏览文件 @
49cb3fc7
...
...
@@ -103,7 +103,7 @@
brief
=
"Convert a char to the corresponding digit. Returns none when
\
character is not a valid hexadecimal digit."
)]
pure
fn
maybe_digit
(
c
:
char
)
->
option
::
t
<
u8
>
{
pure
fn
maybe_digit
(
c
:
char
)
->
option
<
u8
>
{
alt
c
{
'0'
to
'9'
{
option
::
some
(
c
as
u8
-
(
'0'
as
u8
))
}
'a'
to
'z'
{
option
::
some
(
c
as
u8
+
10u8
-
(
'a'
as
u8
))
}
...
...
src/libcore/extfmt.rs
浏览文件 @
49cb3fc7
...
...
@@ -69,7 +69,7 @@ enum count {
// A formatted conversion from an expression to a string
type
conv
=
{
param
:
option
::
t
<
int
>
,
{
param
:
option
<
int
>
,
flags
:
[
flag
],
width
:
count
,
precision
:
count
,
...
...
@@ -115,7 +115,7 @@ fn flush_buf(buf: str, &pieces: [piece]) -> str {
ret
pieces
;
}
fn
peek_num
(
s
:
str
,
i
:
uint
,
lim
:
uint
)
->
option
::
t
<
{
num
:
uint
,
next
:
uint
}
>
{
option
<
{
num
:
uint
,
next
:
uint
}
>
{
if
i
>=
lim
{
ret
none
;
}
let
c
=
s
[
i
];
if
!
(
'0'
as
u8
<=
c
&&
c
<=
'9'
as
u8
)
{
ret
option
::
none
;
}
...
...
@@ -145,7 +145,7 @@ fn parse_conversion(s: str, i: uint, lim: uint, error: error_fn) ->
next
:
ty
.next
};
}
fn
parse_parameter
(
s
:
str
,
i
:
uint
,
lim
:
uint
)
->
{
param
:
option
::
t
<
int
>
,
next
:
uint
}
{
{
param
:
option
<
int
>
,
next
:
uint
}
{
if
i
>=
lim
{
ret
{
param
:
none
,
next
:
i
};
}
let
num
=
peek_num
(
s
,
i
,
lim
);
ret
alt
num
{
...
...
src/libcore/task.rs
浏览文件 @
49cb3fc7
...
...
@@ -122,7 +122,7 @@ fn spawn(+f: fn~()) -> task {
}
fn
spawn_inner
(
-
f
:
fn
~
(),
notify
:
option
::
t
<
comm
::
chan
<
task_notification
>>
)
->
task
unsafe
{
notify
:
option
<
comm
::
chan
<
task_notification
>>
)
->
task
unsafe
{
let
closure
:
*
rust_closure
=
unsafe
::
reinterpret_cast
(
ptr
::
addr_of
(
f
));
#
debug
(
"spawn: closure={%x,%x}"
,
(
*
closure
)
.fnptr
,
(
*
closure
)
.envptr
);
let
id
=
rustrt
::
new_task
();
...
...
src/libcore/vec.rs
浏览文件 @
49cb3fc7
...
...
@@ -230,7 +230,7 @@ fn init<T: copy>(v: [const T]) -> [T] {
An option containing the last element of `v` if `v` is not empty, or
none if `v` is empty.
*/
pure
fn
last
<
T
:
copy
>
(
v
:
[
const
T
])
->
option
::
t
<
T
>
{
pure
fn
last
<
T
:
copy
>
(
v
:
[
const
T
])
->
option
<
T
>
{
if
len
(
v
)
==
0u
{
ret
none
;
}
ret
some
(
v
[
len
(
v
)
-
1u
]);
}
...
...
@@ -445,7 +445,7 @@ fn map2<T: copy, U: copy, V>(v0: [T], v1: [U], f: fn(T, U) -> V) -> [V] {
If function `f` returns `none` then that element is excluded from
the resulting vector.
*/
fn
filter_map
<
T
:
copy
,
U
:
copy
>
(
v
:
[
const
T
],
f
:
fn
(
T
)
->
option
::
t
<
U
>
)
fn
filter_map
<
T
:
copy
,
U
:
copy
>
(
v
:
[
const
T
],
f
:
fn
(
T
)
->
option
<
U
>
)
->
[
U
]
{
let
result
=
[];
for
elem
:
T
in
v
{
...
...
@@ -599,7 +599,7 @@ fn count<T>(x: T, v: [const T]) -> uint {
When function `f` returns true then an option containing the element
is returned. If `f` matches no elements then none is returned.
*/
fn
find
<
T
:
copy
>
(
v
:
[
T
],
f
:
fn
(
T
)
->
bool
)
->
option
::
t
<
T
>
{
fn
find
<
T
:
copy
>
(
v
:
[
T
],
f
:
fn
(
T
)
->
bool
)
->
option
<
T
>
{
for
elt
:
T
in
v
{
if
f
(
elt
)
{
ret
some
(
elt
);
}
}
ret
none
;
}
...
...
@@ -614,7 +614,7 @@ fn find<T: copy>(v: [T], f: fn(T) -> bool) -> option::t<T> {
option::some(uint) - The first index containing a matching value
option::none - No elements matched
*/
fn
position
<
T
>
(
x
:
T
,
v
:
[
T
])
->
option
::
t
<
uint
>
{
fn
position
<
T
>
(
x
:
T
,
v
:
[
T
])
->
option
<
uint
>
{
let
i
:
uint
=
0u
;
while
i
<
len
(
v
)
{
if
x
==
v
[
i
]
{
ret
some
::
<
uint
>
(
i
);
}
i
+=
1u
;
}
ret
none
;
...
...
@@ -625,7 +625,7 @@ fn position<T>(x: T, v: [T]) -> option::t<uint> {
Find the first index for which the value matches some predicate
*/
fn
position_pred
<
T
>
(
v
:
[
T
],
f
:
fn
(
T
)
->
bool
)
->
option
::
t
<
uint
>
{
fn
position_pred
<
T
>
(
v
:
[
T
],
f
:
fn
(
T
)
->
bool
)
->
option
<
uint
>
{
let
i
:
uint
=
0u
;
while
i
<
len
(
v
)
{
if
f
(
v
[
i
])
{
ret
some
::
<
uint
>
(
i
);
}
i
+=
1u
;
}
ret
none
;
...
...
@@ -1010,7 +1010,7 @@ mod tests {
pure
fn
is_equal
(
&&
x
:
uint
,
&&
y
:
uint
)
->
bool
{
ret
x
==
y
;
}
fn
square_if_odd
(
&&
n
:
uint
)
->
option
::
t
<
uint
>
{
fn
square_if_odd
(
&&
n
:
uint
)
->
option
<
uint
>
{
ret
if
n
%
2u
==
1u
{
some
(
n
*
n
)
}
else
{
none
};
}
...
...
@@ -1267,7 +1267,7 @@ fn test_filter_map() {
assert
(
w
[
1
]
==
9u
);
assert
(
w
[
2
]
==
25u
);
fn
halve
(
&&
i
:
int
)
->
option
::
t
<
int
>
{
fn
halve
(
&&
i
:
int
)
->
option
<
int
>
{
if
i
%
2
==
0
{
ret
option
::
some
::
<
int
>
(
i
/
2
);
}
else
{
ret
option
::
none
::
<
int
>
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录