Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
c0c8d3aa
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,发现更多精彩内容 >>
提交
c0c8d3aa
编写于
8月 29, 2012
作者:
B
Brian Anderson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
core: Demode int/uint mods
上级
ee2ce036
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
34 addition
and
26 deletion
+34
-26
src/libcore/int-template.rs
src/libcore/int-template.rs
+8
-4
src/libcore/io.rs
src/libcore/io.rs
+1
-1
src/libcore/str.rs
src/libcore/str.rs
+1
-1
src/libcore/uint-template.rs
src/libcore/uint-template.rs
+8
-4
src/libcore/vec.rs
src/libcore/vec.rs
+2
-2
src/libstd/arena.rs
src/libstd/arena.rs
+2
-2
src/libstd/net_tcp.rs
src/libstd/net_tcp.rs
+1
-1
src/libstd/par.rs
src/libstd/par.rs
+2
-2
src/libstd/rope.rs
src/libstd/rope.rs
+1
-1
src/libsyntax/ast_util.rs
src/libsyntax/ast_util.rs
+2
-2
src/libsyntax/parse/comments.rs
src/libsyntax/parse/comments.rs
+1
-1
src/rustc/back/rpath.rs
src/rustc/back/rpath.rs
+1
-1
src/rustc/driver/rustc.rs
src/rustc/driver/rustc.rs
+1
-1
src/rustc/middle/trans/foreign.rs
src/rustc/middle/trans/foreign.rs
+1
-1
src/rustc/middle/ty.rs
src/rustc/middle/ty.rs
+2
-2
未找到文件。
src/libcore/int-template.rs
浏览文件 @
c0c8d3aa
// NB: transitionary, de-mode-ing.
#[forbid(deprecated_mode)]
;
#[forbid(deprecated_pattern)]
;
import
T
=
inst
::
T
;
import
cmp
::{
Eq
,
Ord
};
import
num
::
from_int
;
...
...
@@ -21,8 +25,8 @@
const
min_value
:
T
=
(
-
1
as
T
)
<<
(
bits
-
1
);
const
max_value
:
T
=
min_value
-
1
as
T
;
pure
fn
min
(
&&
x
:
T
,
&&
y
:
T
)
->
T
{
if
x
<
y
{
x
}
else
{
y
}
}
pure
fn
max
(
&&
x
:
T
,
&&
y
:
T
)
->
T
{
if
x
>
y
{
x
}
else
{
y
}
}
pure
fn
min
(
x
:
&
T
,
y
:
&
T
)
->
T
{
if
*
x
<
*
y
{
*
x
}
else
{
*
y
}
}
pure
fn
max
(
x
:
&
T
,
y
:
&
T
)
->
T
{
if
*
x
>
*
y
{
*
x
}
else
{
*
y
}
}
pure
fn
add
(
x
:
&
T
,
y
:
&
T
)
->
T
{
*
x
+
*
y
}
pure
fn
sub
(
x
:
&
T
,
y
:
&
T
)
->
T
{
*
x
-
*
y
}
...
...
@@ -155,7 +159,7 @@ fn parse_buf(buf: ~[u8], radix: uint) -> Option<T> {
}
/// Parse a string to an int
fn
from_str
(
s
:
~
str
)
->
Option
<
T
>
{
parse_buf
(
str
::
to_bytes
(
s
),
10u
)
}
fn
from_str
(
s
:
&
str
)
->
Option
<
T
>
{
parse_buf
(
str
::
to_bytes
(
s
),
10u
)
}
/// Convert to a string in a given base
fn
to_str
(
n
:
T
,
radix
:
uint
)
->
~
str
{
...
...
@@ -235,7 +239,7 @@ fn test_to_str() {
#[test]
fn
test_interfaces
()
{
fn
test
<
U
:
num
::
Num
>
(
ten
:
U
)
{
fn
test
<
U
:
num
::
Num
>
(
+
ten
:
U
)
{
assert
(
ten
.to_int
()
==
10
);
let
two
:
U
=
from_int
(
2
);
...
...
src/libcore/io.rs
浏览文件 @
c0c8d3aa
...
...
@@ -284,7 +284,7 @@ fn file_reader(path: &Path) -> Result<Reader, ~str> {
impl
ByteBuf
:
Reader
{
fn
read
(
buf
:
&
[
mut
u8
],
len
:
uint
)
->
uint
{
let
count
=
uint
::
min
(
len
,
self
.buf
.len
()
-
self
.pos
);
let
count
=
uint
::
min
(
&
len
,
&
(
self
.buf
.len
()
-
self
.pos
)
);
vec
::
u8
::
memcpy
(
buf
,
vec
::
const_view
(
self
.buf
,
self
.pos
,
self
.buf
.len
()),
...
...
src/libcore/str.rs
浏览文件 @
c0c8d3aa
...
...
@@ -676,7 +676,7 @@ fn view_shift_char(s: &a/str) -> (char, &a/str) {
let
a_len
=
a
.len
();
let
b_len
=
b
.len
();
if
a_len
!=
b_len
{
return
false
;
}
let
mut
end
=
uint
::
min
(
a_len
,
b_len
);
let
mut
end
=
uint
::
min
(
&
a_len
,
&
b_len
);
let
mut
i
=
0u
;
while
i
<
end
{
...
...
src/libcore/uint-template.rs
浏览文件 @
c0c8d3aa
// NB: transitionary, de-mode-ing.
#[forbid(deprecated_mode)]
;
#[forbid(deprecated_pattern)]
;
import
T
=
inst
::
T
;
import
cmp
::{
Eq
,
Ord
};
...
...
@@ -20,8 +24,8 @@
const
min_value
:
T
=
0
as
T
;
const
max_value
:
T
=
0
as
T
-
1
as
T
;
pure
fn
min
(
&&
x
:
T
,
&&
y
:
T
)
->
T
{
if
x
<
y
{
x
}
else
{
y
}
}
pure
fn
max
(
&&
x
:
T
,
&&
y
:
T
)
->
T
{
if
x
>
y
{
x
}
else
{
y
}
}
pure
fn
min
(
x
:
&
T
,
y
:
&
T
)
->
T
{
if
*
x
<
*
y
{
*
x
}
else
{
*
y
}
}
pure
fn
max
(
x
:
&
T
,
y
:
&
T
)
->
T
{
if
*
x
>
*
y
{
*
x
}
else
{
*
y
}
}
pure
fn
add
(
x
:
&
T
,
y
:
&
T
)
->
T
{
*
x
+
*
y
}
pure
fn
sub
(
x
:
&
T
,
y
:
&
T
)
->
T
{
*
x
-
*
y
}
...
...
@@ -138,10 +142,10 @@ fn parse_buf(buf: &[const u8], radix: uint) -> Option<T> {
}
/// Parse a string to an int
fn
from_str
(
s
:
~
str
)
->
Option
<
T
>
{
parse_buf
(
str
::
to_bytes
(
s
),
10u
)
}
fn
from_str
(
s
:
&
str
)
->
Option
<
T
>
{
parse_buf
(
str
::
to_bytes
(
s
),
10u
)
}
/// Parse a string as an unsigned integer.
fn
from_str_radix
(
buf
:
~
str
,
radix
:
u64
)
->
Option
<
u64
>
{
fn
from_str_radix
(
buf
:
&
str
,
radix
:
u64
)
->
Option
<
u64
>
{
if
str
::
len
(
buf
)
==
0u
{
return
None
;
}
let
mut
i
=
str
::
len
(
buf
)
-
1u
;
let
mut
power
=
1u64
,
n
=
0u64
;
...
...
src/libcore/vec.rs
浏览文件 @
c0c8d3aa
...
...
@@ -1430,7 +1430,7 @@ impl<T: Eq> @[T]: Eq {
pure
fn
lt
<
T
:
Ord
>
(
a
:
&
[
T
],
b
:
&
[
T
])
->
bool
{
let
(
a_len
,
b_len
)
=
(
a
.len
(),
b
.len
());
let
mut
end
=
uint
::
min
(
a_len
,
b_len
);
let
mut
end
=
uint
::
min
(
&
a_len
,
&
b_len
);
let
mut
i
=
0
;
while
i
<
end
{
...
...
@@ -1821,7 +1821,7 @@ mod u8 {
pure
fn
cmp
(
a
:
&~
[
u8
],
b
:
&~
[
u8
])
->
int
{
let
a_len
=
len
(
*
a
);
let
b_len
=
len
(
*
b
);
let
n
=
uint
::
min
(
a_len
,
b_len
)
as
libc
::
size_t
;
let
n
=
uint
::
min
(
&
a_len
,
&
b_len
)
as
libc
::
size_t
;
let
r
=
unsafe
{
libc
::
memcmp
(
unsafe
::
to_ptr
(
*
a
)
as
*
libc
::
c_void
,
unsafe
::
to_ptr
(
*
b
)
as
*
libc
::
c_void
,
n
)
as
int
...
...
src/libstd/arena.rs
浏览文件 @
c0c8d3aa
...
...
@@ -135,7 +135,7 @@ impl &Arena {
fn
alloc_pod_grow
(
n_bytes
:
uint
,
align
:
uint
)
->
*
u8
{
// Allocate a new chunk.
let
chunk_size
=
at_vec
::
capacity
(
self
.pod_head.data
);
let
new_min_chunk_size
=
uint
::
max
(
n_bytes
,
chunk_size
);
let
new_min_chunk_size
=
uint
::
max
(
&
n_bytes
,
&
chunk_size
);
self
.chunks
=
@
cons
(
copy
self
.pod_head
,
self
.chunks
);
self
.pod_head
=
chunk
(
uint
::
next_power_of_two
(
new_min_chunk_size
+
1u
),
true
);
...
...
@@ -177,7 +177,7 @@ fn alloc_pod<T>(op: fn() -> T) -> &self/T {
fn
alloc_nonpod_grow
(
n_bytes
:
uint
,
align
:
uint
)
->
(
*
u8
,
*
u8
)
{
// Allocate a new chunk.
let
chunk_size
=
at_vec
::
capacity
(
self
.head.data
);
let
new_min_chunk_size
=
uint
::
max
(
n_bytes
,
chunk_size
);
let
new_min_chunk_size
=
uint
::
max
(
&
n_bytes
,
&
chunk_size
);
self
.chunks
=
@
cons
(
copy
self
.head
,
self
.chunks
);
self
.head
=
chunk
(
uint
::
next_power_of_two
(
new_min_chunk_size
+
1u
),
false
);
...
...
src/libstd/net_tcp.rs
浏览文件 @
c0c8d3aa
...
...
@@ -772,7 +772,7 @@ fn read(buf: &[mut u8], len: uint) -> uint {
}
}
let
count
=
uint
::
min
(
len
,
self
.data.buf
.len
());
let
count
=
uint
::
min
(
&
len
,
&
self
.data.buf
.len
());
let
mut
data
=
~
[];
self
.data.buf
<->
data
;
...
...
src/libstd/par.rs
浏览文件 @
c0c8d3aa
...
...
@@ -30,7 +30,7 @@ fn map_slices<A: copy send, B: copy send>(
~
[
f
()(
0u
,
xs
)]
}
else
{
let
num_tasks
=
uint
::
min
(
max_tasks
,
len
/
min_granularity
);
let
num_tasks
=
uint
::
min
(
&
max_tasks
,
&
(
len
/
min_granularity
)
);
let
items_per_task
=
len
/
num_tasks
;
...
...
@@ -38,7 +38,7 @@ fn map_slices<A: copy send, B: copy send>(
let
mut
base
=
0u
;
log
(
info
,
~
"spawning tasks"
);
while
base
<
len
{
let
end
=
uint
::
min
(
len
,
base
+
items_per_task
);
let
end
=
uint
::
min
(
&
len
,
&
(
base
+
items_per_task
)
);
// FIXME: why is the ::<A, ()> annotation required here? (#2617)
do
vec
::
as_buf
::
<
A
,
()
>
(
xs
)
|
p
,
_
len
|
{
let
f
=
f
();
...
...
src/libstd/rope.rs
浏览文件 @
c0c8d3aa
...
...
@@ -1002,7 +1002,7 @@ fn concat2(left: @node, right: @node) -> @node {
right
:
right
,
char_len
:
char_len
(
left
)
+
char_len
(
right
),
byte_len
:
byte_len
(
left
)
+
byte_len
(
right
),
height
:
uint
::
max
(
height
(
left
),
height
(
right
))
+
1u
height
:
uint
::
max
(
&
height
(
left
),
&
height
(
right
))
+
1u
})
}
...
...
src/libsyntax/ast_util.rs
浏览文件 @
c0c8d3aa
...
...
@@ -563,8 +563,8 @@ fn compute_id_range(visit_ids_fn: fn(fn@(node_id))) -> id_range {
let
min
=
@
mut
int
::
max_value
;
let
max
=
@
mut
int
::
min_value
;
do
visit_ids_fn
|
id
|
{
*
min
=
int
::
min
(
*
min
,
id
);
*
max
=
int
::
max
(
*
max
,
id
+
1
);
*
min
=
int
::
min
(
min
,
&
id
);
*
max
=
int
::
max
(
max
,
&
(
id
+
1
)
);
}
return
{
min
:
*
min
,
max
:
*
max
};
}
...
...
src/libsyntax/parse/comments.rs
浏览文件 @
c0c8d3aa
...
...
@@ -182,7 +182,7 @@ fn trim_whitespace_prefix_and_push_line(&lines: ~[~str],
s
:
~
str
,
col
:
uint
)
unsafe
{
let
mut
s1
;
let
len
=
str
::
len
(
s
);
if
all_whitespace
(
s
,
0u
,
uint
::
min
(
len
,
col
))
{
if
all_whitespace
(
s
,
0u
,
uint
::
min
(
&
len
,
&
col
))
{
if
col
<
len
{
s1
=
str
::
slice
(
s
,
col
,
len
);
}
else
{
s1
=
~
""
;
}
...
...
src/rustc/back/rpath.rs
浏览文件 @
c0c8d3aa
...
...
@@ -128,7 +128,7 @@ fn get_relative_to(abs1: &Path, abs2: &Path) -> Path {
assert
len1
>
0u
;
assert
len2
>
0u
;
let
max_common_path
=
uint
::
min
(
len1
,
len2
)
-
1u
;
let
max_common_path
=
uint
::
min
(
&
len1
,
&
len2
)
-
1u
;
let
mut
start_idx
=
0u
;
while
start_idx
<
max_common_path
&&
split1
[
start_idx
]
==
split2
[
start_idx
]
{
...
...
src/rustc/driver/rustc.rs
浏览文件 @
c0c8d3aa
...
...
@@ -81,7 +81,7 @@ fn usage(argv0: ~str) {
fn
describe_warnings
()
{
let
lint_dict
=
lint
::
get_lint_dict
();
let
mut
max_key
=
0u
;
for
lint_dict
.each_key
|
k
|
{
max_key
=
uint
::
max
(
k
.len
(),
max_key
);
}
for
lint_dict
.each_key
|
k
|
{
max_key
=
uint
::
max
(
&
k
.len
(),
&
max_key
);
}
fn
padded
(
max
:
uint
,
s
:
~
str
)
->
~
str
{
str
::
from_bytes
(
vec
::
from_elem
(
max
-
s
.len
(),
' '
as
u8
))
+
s
}
...
...
src/rustc/middle/trans/foreign.rs
浏览文件 @
c0c8d3aa
...
...
@@ -82,7 +82,7 @@ fn ty_align(ty: TypeRef) -> uint {
3
/* double */
=>
8u
,
10
/* struct */
=>
{
do
vec
::
foldl
(
0u
,
struct_tys
(
ty
))
|
a
,
t
|
{
uint
::
max
(
a
,
ty_align
(
t
))
uint
::
max
(
&
a
,
&
ty_align
(
t
))
}
}
11
/* array */
=>
{
...
...
src/rustc/middle/ty.rs
浏览文件 @
c0c8d3aa
...
...
@@ -1856,9 +1856,9 @@ fn type_size(cx: ctxt, ty: t) -> uint {
let
variants
=
substd_enum_variants
(
cx
,
did
,
substs
);
variants
.foldl
(
// find max size of any variant
0
,
|
m
,
v
|
uint
::
max
(
m
,
|
m
,
v
|
uint
::
max
(
&
m
,
// find size of this variant:
v
.args
.foldl
(
0
,
|
s
,
a
|
s
+
type_size
(
cx
,
a
))))
&
v
.args
.foldl
(
0
,
|
s
,
a
|
s
+
type_size
(
cx
,
a
))))
}
ty_param
(
_
)
|
ty_self
=>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录