Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
89acd1f5
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,发现更多精彩内容 >>
提交
89acd1f5
编写于
1月 04, 2013
作者:
T
Tim Chevalier
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename option::get_default => get_or_default, get_zero => get_or_zero
上级
4d8cc3f0
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
20 addition
and
20 deletion
+20
-20
src/libcore/at_vec.rs
src/libcore/at_vec.rs
+1
-1
src/libcore/iter.rs
src/libcore/iter.rs
+1
-1
src/libcore/option.rs
src/libcore/option.rs
+7
-7
src/libcore/os.rs
src/libcore/os.rs
+2
-2
src/libcore/vec.rs
src/libcore/vec.rs
+1
-1
src/librustc/metadata/filesearch.rs
src/librustc/metadata/filesearch.rs
+3
-3
src/librustc/middle/trans/alt.rs
src/librustc/middle/trans/alt.rs
+1
-1
src/librustc/middle/trans/monomorphize.rs
src/librustc/middle/trans/monomorphize.rs
+1
-1
src/librustdoc/attr_pass.rs
src/librustdoc/attr_pass.rs
+1
-1
src/librustdoc/config.rs
src/librustdoc/config.rs
+1
-1
src/libsyntax/parse/comments.rs
src/libsyntax/parse/comments.rs
+1
-1
未找到文件。
src/libcore/at_vec.rs
浏览文件 @
89acd1f5
...
...
@@ -100,7 +100,7 @@ fn vec_reserve_shared_actual(++t: *sys::TypeDesc,
#[inline(always)]
pub
pure
fn
build_sized_opt
<
A
>
(
size
:
Option
<
uint
>
,
builder
:
&
fn
(
push
:
pure
fn
(
v
:
A
)))
->
@
[
A
]
{
build_sized
(
size
.get_default
(
4
),
builder
)
build_sized
(
size
.get_
or_
default
(
4
),
builder
)
}
// Appending
...
...
src/libcore/iter.rs
浏览文件 @
89acd1f5
...
...
@@ -267,7 +267,7 @@ pub trait Buildable<A> {
size
:
Option
<
uint
>
,
builder
:
fn
(
push
:
pure
fn
(
A
)))
->
B
{
Buildable
::
build_sized
(
size
.get_default
(
4
),
builder
)
Buildable
::
build_sized
(
size
.get_
or_
default
(
4
),
builder
)
}
// Functions that combine iteration and building
...
...
src/libcore/option.rs
浏览文件 @
89acd1f5
...
...
@@ -171,13 +171,13 @@ pub enum Option<T> {
!
is_none
(
opt
)
}
pub
pure
fn
get_zero
<
T
:
Copy
Zero
>
(
opt
:
Option
<
T
>
)
->
T
{
pub
pure
fn
get_
or_
zero
<
T
:
Copy
Zero
>
(
opt
:
Option
<
T
>
)
->
T
{
//! Returns the contained value or zero (for this type)
match
opt
{
Some
(
copy
x
)
=>
x
,
None
=>
Zero
::
zero
()
}
}
pub
pure
fn
get_default
<
T
:
Copy
>
(
opt
:
Option
<
T
>
,
def
:
T
)
->
T
{
pub
pure
fn
get_
or_
default
<
T
:
Copy
>
(
opt
:
Option
<
T
>
,
def
:
T
)
->
T
{
//! Returns the contained value or a default
match
opt
{
Some
(
copy
x
)
=>
x
,
None
=>
def
}
...
...
@@ -331,7 +331,7 @@ impl<T: Copy> Option<T> {
pure
fn
get
(
self
)
->
T
{
get
(
self
)
}
#[inline(always)]
pure
fn
get_
default
(
self
,
def
:
T
)
->
T
{
get
_default
(
self
,
def
)
}
pure
fn
get_
or_default
(
self
,
def
:
T
)
->
T
{
get_or
_default
(
self
,
def
)
}
/// Applies a function zero or more times until the result is none.
#[inline(always)]
...
...
@@ -342,7 +342,7 @@ impl<T: Copy> Option<T> {
impl
<
T
:
Copy
Zero
>
Option
<
T
>
{
#[inline(always)]
pure
fn
get_
zero
(
self
)
->
T
{
get
_zero
(
self
)
}
pure
fn
get_
or_zero
(
self
)
->
T
{
get_or
_zero
(
self
)
}
}
#[test]
...
...
@@ -420,11 +420,11 @@ fn test_option_while_some() {
}
#[test]
fn
test_get_zero
()
{
fn
test_get_
or_
zero
()
{
let
some_stuff
=
Some
(
42
);
assert
some_stuff
.get_zero
()
==
42
;
assert
some_stuff
.get_
or_
zero
()
==
42
;
let
no_stuff
:
Option
<
int
>
=
None
;
assert
no_stuff
.get_zero
()
==
0
;
assert
no_stuff
.get_
or_
zero
()
==
0
;
}
// Local Variables:
...
...
src/libcore/os.rs
浏览文件 @
89acd1f5
...
...
@@ -510,14 +510,14 @@ fn getenv_nonempty(v: &str) -> Option<Path> {
#[cfg(unix)]
#[allow(non_implicitly_copyable_typarams)]
fn
lookup
()
->
Path
{
option
::
get_default
(
getenv_nonempty
(
"TMPDIR"
),
option
::
get_
or_
default
(
getenv_nonempty
(
"TMPDIR"
),
Path
(
"/tmp"
))
}
#[cfg(windows)]
#[allow(non_implicitly_copyable_typarams)]
fn
lookup
()
->
Path
{
option
::
get_default
(
option
::
get_
or_
default
(
option
::
or
(
getenv_nonempty
(
"TMP"
),
option
::
or
(
getenv_nonempty
(
"TEMP"
),
option
::
or
(
getenv_nonempty
(
"USERPROFILE"
),
...
...
src/libcore/vec.rs
浏览文件 @
89acd1f5
...
...
@@ -203,7 +203,7 @@ pub fn reserve_at_least<T>(v: &mut ~[T], n: uint) {
#[inline(always)]
pub
pure
fn
build_sized_opt
<
A
>
(
size
:
Option
<
uint
>
,
builder
:
fn
(
push
:
pure
fn
(
v
:
A
)))
->
~
[
A
]
{
build_sized
(
size
.get_default
(
4
),
builder
)
build_sized
(
size
.get_
or_
default
(
4
),
builder
)
}
/// Produces a mut vector from an immutable vector.
...
...
src/librustc/metadata/filesearch.rs
浏览文件 @
89acd1f5
...
...
@@ -113,7 +113,7 @@ fn make_target_lib_path(sysroot: &Path,
sysroot
.push_rel
(
&
relative_target_lib_path
(
target_triple
))
}
fn
get_default_sysroot
()
->
Path
{
fn
get_
or_
default_sysroot
()
->
Path
{
match
os
::
self_exe_path
()
{
option
::
Some
(
ref
p
)
=>
(
*
p
)
.pop
(),
option
::
None
=>
fail
~
"can't determine value for sysroot"
...
...
@@ -123,12 +123,12 @@ fn get_default_sysroot() -> Path {
fn
get_sysroot
(
maybe_sysroot
:
Option
<
Path
>
)
->
Path
{
match
maybe_sysroot
{
option
::
Some
(
ref
sr
)
=>
(
*
sr
),
option
::
None
=>
get_default_sysroot
()
option
::
None
=>
get_
or_
default_sysroot
()
}
}
fn
get_cargo_sysroot
()
->
Result
<
Path
,
~
str
>
{
result
::
Ok
(
get_default_sysroot
()
.push_many
([
libdir
(),
~
"cargo"
]))
result
::
Ok
(
get_
or_
default_sysroot
()
.push_many
([
libdir
(),
~
"cargo"
]))
}
fn
get_cargo_root
()
->
Result
<
Path
,
~
str
>
{
...
...
src/librustc/middle/trans/alt.rs
浏览文件 @
89acd1f5
...
...
@@ -502,7 +502,7 @@ fn enter_opt(bcx: block, m: &[@Match/&r], opt: &Opt, col: uint,
match
p
.node
{
ast
::
pat_enum
(
_
,
subpats
)
=>
{
if
opt_eq
(
tcx
,
&
variant_opt
(
tcx
,
p
.id
),
opt
)
{
Some
(
option
::
get_default
(
subpats
,
Some
(
option
::
get_
or_
default
(
subpats
,
vec
::
from_elem
(
variant_size
,
dummy
)))
}
else
{
...
...
src/librustc/middle/trans/monomorphize.rs
浏览文件 @
89acd1f5
...
...
@@ -136,7 +136,7 @@ fn monomorphic_fn(ccx: @crate_ctxt,
ccx
.stats.n_monos
+=
1
;
let
depth
=
option
::
get_default
(
ccx
.monomorphizing
.find
(
fn_id
),
0u
);
let
depth
=
option
::
get_
or_
default
(
ccx
.monomorphizing
.find
(
fn_id
),
0u
);
// Random cut-off -- code that needs to instantiate the same function
// recursively more than ten times can probably safely be assumed to be
// causing an infinite expansion.
...
...
src/librustdoc/attr_pass.rs
浏览文件 @
89acd1f5
...
...
@@ -69,7 +69,7 @@ fn fold_crate(
{
topmod
:
doc
::
ModDoc_
({
item
:
{
name
:
option
::
get_default
(
attrs
.name
,
doc
.topmod
.name
()),
name
:
option
::
get_
or_
default
(
attrs
.name
,
doc
.topmod
.name
()),
..
doc
.topmod.item
},
..
*
doc
.topmod
...
...
src/librustdoc/config.rs
浏览文件 @
89acd1f5
...
...
@@ -154,7 +154,7 @@ fn config_from_opts(
let
output_dir
=
getopts
::
opt_maybe_str
(
matches
,
opt_output_dir
());
let
output_dir
=
output_dir
.map
(|
s
|
Path
(
*
s
));
result
::
Ok
({
output_dir
:
output_dir
.get_default
(
config
.output_dir
),
output_dir
:
output_dir
.get_
or_
default
(
config
.output_dir
),
..
config
})
};
...
...
src/libsyntax/parse/comments.rs
浏览文件 @
89acd1f5
...
...
@@ -83,7 +83,7 @@ fn vertical_trim(lines: ~[~str]) -> ~[~str] {
// drop leftmost columns that contain only values in chars
fn
block_trim
(
lines
:
~
[
~
str
],
chars
:
~
str
,
max
:
Option
<
uint
>
)
->
~
[
~
str
]
{
let
mut
i
=
max
.get_default
(
uint
::
max_value
);
let
mut
i
=
max
.get_
or_
default
(
uint
::
max_value
);
for
lines
.each
|
line
|
{
if
line
.trim
()
.is_empty
()
{
loop
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录