Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
151b7ed5
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,发现更多精彩内容 >>
提交
151b7ed5
编写于
11月 22, 2013
作者:
P
Patrick Walton
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
libstd: Fix Win32 and other bustage.
上级
749ee53c
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
41 addition
and
39 deletion
+41
-39
src/libstd/condition.rs
src/libstd/condition.rs
+5
-5
src/libstd/gc.rs
src/libstd/gc.rs
+4
-4
src/libstd/io/native/file.rs
src/libstd/io/native/file.rs
+3
-1
src/libstd/io/native/process.rs
src/libstd/io/native/process.rs
+1
-1
src/libstd/num/mod.rs
src/libstd/num/mod.rs
+1
-1
src/libstd/num/uint.rs
src/libstd/num/uint.rs
+2
-2
src/libstd/ops.rs
src/libstd/ops.rs
+2
-2
src/libstd/rand/os.rs
src/libstd/rand/os.rs
+2
-2
src/libstd/rt/args.rs
src/libstd/rt/args.rs
+5
-5
src/libstd/vec.rs
src/libstd/vec.rs
+16
-16
未找到文件。
src/libstd/condition.rs
浏览文件 @
151b7ed5
...
...
@@ -30,14 +30,14 @@
parameters are used for, an example usage of this condition would be:
```rust
do
my_error::cond.trap(|raised_int| {
my_error::cond.trap(|raised_int| {
// the condition `my_error` was raised on, and the value it raised is stored
// in `raised_int`. This closure must return a `~str` type (as specified in
// the declaration of the condition
if raised_int == 3 { ~"three" } else { ~"oh well" }
}).inside {
}).inside
(||
{
// The condition handler above is installed for the duration of this block.
// That handler will override any previous handler, but the previous handler
...
...
@@ -50,7 +50,7 @@
println(my_error::cond.raise(3)); // prints "three"
println(my_error::cond.raise(4)); // prints "oh well"
}
}
)
```
Condition handling is useful in cases where propagating errors is either to
...
...
@@ -176,9 +176,9 @@ impl<'self, T, U> Trap<'self, T, U> {
/// ```rust
/// condition! { my_error: int -> int; }
///
/// let result =
do my_error::cond.trap(|error| error + 3).inside
{
/// let result =
my_error::cond.trap(|error| error + 3).inside(||
{
/// my_error::cond.raise(4)
/// };
/// }
)
;
/// assert_eq!(result, 7);
/// ```
pub
fn
inside
<
V
>
(
&
self
,
inner
:
'self
||
->
V
)
->
V
{
...
...
src/libstd/gc.rs
浏览文件 @
151b7ed5
...
...
@@ -61,9 +61,9 @@ mod tests {
fn
test_clone
()
{
let
x
=
Gc
::
new
(
RefCell
::
new
(
5
));
let
y
=
x
.clone
();
do
x
.borrow
()
.with_mut
|
inner
|
{
x
.borrow
()
.with_mut
(
|
inner
|
{
*
inner
=
20
;
}
}
);
assert_eq!
(
y
.borrow
()
.with
(|
x
|
*
x
),
20
);
}
...
...
@@ -71,9 +71,9 @@ fn test_clone() {
fn
test_deep_clone
()
{
let
x
=
Gc
::
new
(
RefCell
::
new
(
5
));
let
y
=
x
.deep_clone
();
do
x
.borrow
()
.with_mut
|
inner
|
{
x
.borrow
()
.with_mut
(
|
inner
|
{
*
inner
=
20
;
}
}
);
assert_eq!
(
y
.borrow
()
.with
(|
x
|
*
x
),
5
);
}
...
...
src/libstd/io/native/file.rs
浏览文件 @
151b7ed5
...
...
@@ -576,7 +576,9 @@ pub fn unlink(p: &CString) -> IoResult<()> {
#[cfg(windows)]
fn
os_unlink
(
p
:
&
CString
)
->
IoResult
<
()
>
{
super
::
mkerr_winbool
(
unsafe
{
as_utf16_p
(
p
.as_str
()
.unwrap
(),
|
buf
|
libc
::
DeleteFileW
(
buf
));
as_utf16_p
(
p
.as_str
()
.unwrap
(),
|
buf
|
{
libc
::
DeleteFileW
(
buf
)
})
})
}
...
...
src/libstd/io/native/process.rs
浏览文件 @
151b7ed5
...
...
@@ -499,7 +499,7 @@ fn with_envp<T>(env: Option<~[(~str, ~str)]>, cb: |*mut c_void| -> T) -> T {
blk
.push
(
0
);
blk
.as_imm_buf
(|
p
,
_
len
|
unsafe
{
cb
(
cast
::
transmute
(
p
))
})
;
blk
.as_imm_buf
(|
p
,
_
len
|
unsafe
{
cb
(
cast
::
transmute
(
p
))
})
}
_
=>
cb
(
ptr
::
mut_null
())
}
...
...
src/libstd/num/mod.rs
浏览文件 @
151b7ed5
...
...
@@ -104,7 +104,7 @@ pub trait Unsigned: Num {}
/// use num::Times;
/// let ten = 10 as uint;
/// let mut accum = 0;
///
do ten.times { accum += 1; }
///
ten.times(|| { accum += 1; })
/// ```
///
pub
trait
Times
{
...
...
src/libstd/num/uint.rs
浏览文件 @
151b7ed5
...
...
@@ -77,13 +77,13 @@ impl num::Times for uint {
#[inline]
///
/// A convenience form for basic repetition. Given a uint `x`,
/// `
do x.times { ... }
` executes the given block x times.
/// `
x.times(|| { ... })
` executes the given block x times.
///
/// Equivalent to `for uint::range(0, x) |_| { ... }`.
///
/// Not defined on all integer types to permit unambiguous
/// use with integer literals of inferred integer-type as
/// the self-value (eg. `
do 100.times { ... }
`).
/// the self-value (eg. `
100.times(|| { ... })
`).
///
fn
times
(
&
self
,
it
:
||)
{
let
mut
i
=
*
self
;
...
...
src/libstd/ops.rs
浏览文件 @
151b7ed5
...
...
@@ -481,8 +481,8 @@ fn drop(&mut self) {
#[bench]
fn
alloc_obj_with_dtor
(
bh
:
&
mut
BenchHarness
)
{
do
bh
.iter
{
bh
.iter
(||
{
HasDtor
{
x
:
10
};
}
}
)
}
}
src/libstd/rand/os.rs
浏览文件 @
151b7ed5
...
...
@@ -111,9 +111,9 @@ fn rust_win32_rand_gen(hProv: HCRYPTPROV, dwLen: DWORD,
pbBuffer
:
*
mut
BYTE
);
}
do
v
.as_mut_buf
|
ptr
,
len
|
{
v
.as_mut_buf
(
|
ptr
,
len
|
{
unsafe
{
rust_win32_rand_gen
(
self
.hcryptprov
,
len
as
DWORD
,
ptr
)}
}
}
)
}
}
...
...
src/libstd/rt/args.rs
浏览文件 @
151b7ed5
...
...
@@ -109,16 +109,16 @@ pub fn clone() -> Option<~[~str]> {
fn
with_lock
<
T
>
(
f
:
||
->
T
)
->
T
{
static
mut
lock
:
Mutex
=
MUTEX_INIT
;
do
(||
{
(||
{
unsafe
{
lock
.lock
();
f
()
}
})
.finally
{
})
.finally
(||
{
unsafe
{
lock
.unlock
();
}
}
}
)
}
fn
get_global_ptr
()
->
*
mut
Option
<~~
[
~
str
]
>
{
...
...
@@ -127,9 +127,9 @@ fn get_global_ptr() -> *mut Option<~~[~str]> {
// Copied from `os`.
unsafe
fn
load_argc_and_argv
(
argc
:
int
,
argv
:
**
u8
)
->
~
[
~
str
]
{
do
vec
::
from_fn
(
argc
as
uint
)
|
i
|
{
vec
::
from_fn
(
argc
as
uint
,
|
i
|
{
str
::
raw
::
from_c_str
(
*
(
argv
as
**
libc
::
c_char
)
.offset
(
i
as
int
))
}
}
)
}
#[cfg(test)]
...
...
src/libstd/vec.rs
浏览文件 @
151b7ed5
...
...
@@ -3894,25 +3894,25 @@ fn connect(bh: &mut BenchHarness) {
#[bench]
fn
push
(
bh
:
&
mut
BenchHarness
)
{
let
mut
vec
:
~
[
uint
]
=
~
[
0u
];
do
bh
.iter
()
{
bh
.iter
(||
{
vec
.push
(
0
);
}
}
)
}
#[bench]
fn
starts_with_same_vector
(
bh
:
&
mut
BenchHarness
)
{
let
vec
:
~
[
uint
]
=
vec
::
from_fn
(
100
,
|
i
|
i
);
do
bh
.iter
()
{
bh
.iter
(||
{
vec
.starts_with
(
vec
);
}
}
)
}
#[bench]
fn
starts_with_single_element
(
bh
:
&
mut
BenchHarness
)
{
let
vec
:
~
[
uint
]
=
~
[
0u
];
do
bh
.iter
()
{
bh
.iter
(||
{
vec
.starts_with
(
vec
);
}
}
)
}
#[bench]
...
...
@@ -3920,25 +3920,25 @@ fn starts_with_diff_one_element_at_end(bh: &mut BenchHarness) {
let
vec
:
~
[
uint
]
=
vec
::
from_fn
(
100
,
|
i
|
i
);
let
mut
match_vec
:
~
[
uint
]
=
vec
::
from_fn
(
99
,
|
i
|
i
);
match_vec
.push
(
0
);
do
bh
.iter
()
{
bh
.iter
(||
{
vec
.starts_with
(
match_vec
);
}
}
)
}
#[bench]
fn
ends_with_same_vector
(
bh
:
&
mut
BenchHarness
)
{
let
vec
:
~
[
uint
]
=
vec
::
from_fn
(
100
,
|
i
|
i
);
do
bh
.iter
()
{
bh
.iter
(||
{
vec
.ends_with
(
vec
);
}
}
)
}
#[bench]
fn
ends_with_single_element
(
bh
:
&
mut
BenchHarness
)
{
let
vec
:
~
[
uint
]
=
~
[
0u
];
do
bh
.iter
()
{
bh
.iter
(||
{
vec
.ends_with
(
vec
);
}
}
)
}
#[bench]
...
...
@@ -3946,16 +3946,16 @@ fn ends_with_diff_one_element_at_beginning(bh: &mut BenchHarness) {
let
vec
:
~
[
uint
]
=
vec
::
from_fn
(
100
,
|
i
|
i
);
let
mut
match_vec
:
~
[
uint
]
=
vec
::
from_fn
(
100
,
|
i
|
i
);
match_vec
[
0
]
=
200
;
do
bh
.iter
()
{
bh
.iter
(||
{
vec
.starts_with
(
match_vec
);
}
}
)
}
#[bench]
fn
contains_last_element
(
bh
:
&
mut
BenchHarness
)
{
let
vec
:
~
[
uint
]
=
vec
::
from_fn
(
100
,
|
i
|
i
);
do
bh
.iter
()
{
bh
.iter
(||
{
vec
.contains
(
&
99u
);
}
}
)
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录