Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
780f8277
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,发现更多精彩内容 >>
提交
780f8277
编写于
2月 23, 2012
作者:
M
Marijn Haverbeke
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Finish cleanup of core::str
Closes #1849
上级
1d2b4b97
变更
24
展开全部
隐藏空白更改
内联
并排
Showing
24 changed file
with
353 addition
and
494 deletion
+353
-494
src/comp/back/link.rs
src/comp/back/link.rs
+5
-8
src/comp/syntax/codemap.rs
src/comp/syntax/codemap.rs
+5
-7
src/comp/syntax/ext/qquote.rs
src/comp/syntax/ext/qquote.rs
+1
-1
src/compiletest/errors.rs
src/compiletest/errors.rs
+1
-1
src/compiletest/header.rs
src/compiletest/header.rs
+1
-1
src/compiletest/runtest.rs
src/compiletest/runtest.rs
+7
-9
src/libcore/extfmt.rs
src/libcore/extfmt.rs
+10
-12
src/libcore/str.rs
src/libcore/str.rs
+278
-410
src/libstd/fs.rs
src/libstd/fs.rs
+8
-12
src/libstd/json.rs
src/libstd/json.rs
+0
-4
src/libstd/rope.rs
src/libstd/rope.rs
+11
-11
src/rustdoc/desc_pass.rs
src/rustdoc/desc_pass.rs
+1
-1
src/rustdoc/markdown_pass.rs
src/rustdoc/markdown_pass.rs
+4
-4
src/rustdoc/trim_pass.rs
src/rustdoc/trim_pass.rs
+1
-1
src/test/bench/sudoku.rs
src/test/bench/sudoku.rs
+1
-1
src/test/compile-fail/fn-constraint.rs
src/test/compile-fail/fn-constraint.rs
+2
-1
src/test/compile-fail/no-constraint-prop.rs
src/test/compile-fail/no-constraint-prop.rs
+2
-1
src/test/run-fail/fn-constraint.rs
src/test/run-fail/fn-constraint.rs
+2
-1
src/test/run-pass/constraint-prop-expr-move.rs
src/test/run-pass/constraint-prop-expr-move.rs
+2
-1
src/test/run-pass/constraint-prop-move.rs
src/test/run-pass/constraint-prop-move.rs
+2
-1
src/test/run-pass/constraint-prop-swap.rs
src/test/run-pass/constraint-prop-swap.rs
+2
-1
src/test/run-pass/constraint-prop.rs
src/test/run-pass/constraint-prop.rs
+3
-2
src/test/run-pass/fn-constraint.rs
src/test/run-pass/fn-constraint.rs
+2
-1
src/test/run-pass/utf8_chars.rs
src/test/run-pass/utf8_chars.rs
+2
-2
未找到文件。
src/comp/back/link.rs
浏览文件 @
780f8277
...
...
@@ -109,13 +109,10 @@ fn is_object_or_assembly_or_exe(ot: output_type) -> bool {
// Decides what to call an intermediate file, given the name of the output
// and the extension to use.
fn
mk_intermediate_name
(
output_path
:
str
,
extension
:
str
)
->
str
unsafe
{
let
stem
=
alt
str
::
index
(
output_path
,
'.'
)
{
option
::
some
(
dot_pos
)
{
str
::
slice
(
output_path
,
0u
,
dot_pos
)
}
option
::
none
{
output_path
}
};
let
stem
=
alt
str
::
find_char
(
output_path
,
'.'
)
{
some
(
dot_pos
)
{
str
::
slice
(
output_path
,
0u
,
dot_pos
)
}
none
{
output_path
}
};
ret
stem
+
"."
+
extension
;
}
...
...
@@ -566,7 +563,7 @@ fn link_binary(sess: session,
// Converts a library file name into a cc -l argument
fn
unlib
(
config
:
@
session
::
config
,
filename
:
str
)
->
str
unsafe
{
let
rmlib
=
fn
@
(
filename
:
str
)
->
str
{
let
found
=
str
::
find
(
filename
,
"lib"
);
let
found
=
str
::
find
_str
(
filename
,
"lib"
);
if
config
.os
==
session
::
os_macos
||
(
config
.os
==
session
::
os_linux
||
config
.os
==
session
::
os_freebsd
)
&&
...
...
src/comp/syntax/codemap.rs
浏览文件 @
780f8277
...
...
@@ -157,7 +157,7 @@ fn span_to_lines(sp: span, cm: codemap::codemap) -> @file_lines {
fn
get_line
(
fm
:
filemap
,
line
:
int
)
->
str
unsafe
{
let
begin
:
uint
=
fm
.lines
[
line
]
.byte
-
fm
.start_pos.byte
;
let
end
=
alt
str
::
index_from
(
*
fm
.src
,
'\n'
,
begin
,
str
::
len
(
*
fm
.src
)
)
{
let
end
=
alt
str
::
find_char_from
(
*
fm
.src
,
'\n'
,
begin
)
{
some
(
e
)
{
e
}
none
{
str
::
len
(
*
fm
.src
)
}
};
...
...
@@ -165,14 +165,12 @@ fn get_line(fm: filemap, line: int) -> str unsafe {
}
fn
lookup_byte_offset
(
cm
:
codemap
::
codemap
,
chpos
:
uint
)
->
{
fm
:
filemap
,
pos
:
uint
}
{
fn
lookup
(
pos
:
file_pos
)
->
uint
{
ret
pos
.ch
;
}
let
{
fm
,
line
}
=
lookup_line
(
cm
,
chpos
,
lookup
);
->
{
fm
:
filemap
,
pos
:
uint
}
{
let
{
fm
,
line
}
=
lookup_line
(
cm
,
chpos
,
{|
pos
|
pos
.ch
});
let
line_offset
=
fm
.lines
[
line
]
.byte
-
fm
.start_pos.byte
;
let
col
=
chpos
-
fm
.lines
[
line
]
.ch
;
let
col_offset
=
str
::
substr_len
(
*
fm
.src
,
line_offset
,
col
);
ret
{
fm
:
fm
,
pos
:
line_offset
+
col_offset
};
let
col_offset
=
str
::
count_bytes
(
*
fm
.src
,
line_offset
,
col
);
{
fm
:
fm
,
pos
:
line_offset
+
col_offset
}
}
fn
span_to_snippet
(
sp
:
span
,
cm
:
codemap
::
codemap
)
->
str
{
...
...
src/comp/syntax/ext/qquote.rs
浏览文件 @
780f8277
...
...
@@ -214,7 +214,7 @@ fn finish<T: qq_helper>
if
(
j
<
g_len
&&
i
==
cx
.gather
[
j
]
.lo
)
{
assert
ch
==
'$'
;
let
repl
=
#
fmt
(
"$%u "
,
j
);
state
=
skip
(
str
::
len_chars
(
repl
));
state
=
skip
(
str
::
char_len
(
repl
));
str2
+=
repl
;
}
alt
state
{
...
...
src/compiletest/errors.rs
浏览文件 @
780f8277
...
...
@@ -25,7 +25,7 @@ fn load_errors(testfile: str) -> [expected_error] {
fn
parse_expected
(
line_num
:
uint
,
line
:
str
)
->
[
expected_error
]
unsafe
{
let
error_tag
=
"//!"
;
let
idx
;
alt
str
::
find
(
line
,
error_tag
)
{
alt
str
::
find
_str
(
line
,
error_tag
)
{
option
::
none
{
ret
[];
}
option
::
some
(
nn
)
{
idx
=
(
nn
as
uint
)
+
str
::
len
(
error_tag
);
}
}
...
...
src/compiletest/header.rs
浏览文件 @
780f8277
...
...
@@ -106,7 +106,7 @@ fn parse_name_directive(line: str, directive: str) -> bool {
fn
parse_name_value_directive
(
line
:
str
,
directive
:
str
)
->
option
<
str
>
unsafe
{
let
keycolon
=
directive
+
":"
;
alt
str
::
find
(
line
,
keycolon
)
{
alt
str
::
find
_str
(
line
,
keycolon
)
{
option
::
some
(
colon
)
{
let
value
=
str
::
slice
(
line
,
colon
+
str
::
len
(
keycolon
),
str
::
len
(
line
));
...
...
src/compiletest/runtest.rs
浏览文件 @
780f8277
...
...
@@ -198,7 +198,7 @@ fn check_error_patterns(props: test_props,
let
next_err_idx
=
0u
;
let
next_err_pat
=
props
.error_patterns
[
next_err_idx
];
for
line
:
str
in
str
::
split_
byte
(
procres
.stderr
,
'\n'
as
u8
)
{
for
line
:
str
in
str
::
split_
char
(
procres
.stderr
,
'\n'
)
{
if
str
::
contains
(
line
,
next_err_pat
)
{
#
debug
(
"found error pattern %s"
,
next_err_pat
);
next_err_idx
+=
1u
;
...
...
@@ -245,7 +245,7 @@ fn check_expected_errors(expected_errors: [errors::expected_error],
// filename:line1:col1: line2:col2: *warning:* msg
// where line1:col1: is the starting point, line2:col2:
// is the ending point, and * represents ANSI color codes.
for
line
:
str
in
str
::
split_
byte
(
procres
.stderr
,
'\n'
as
u8
)
{
for
line
:
str
in
str
::
split_
char
(
procres
.stderr
,
'\n'
)
{
let
was_expected
=
false
;
vec
::
iteri
(
expected_errors
)
{|
i
,
ee
|
if
!
found_flags
[
i
]
{
...
...
@@ -350,7 +350,7 @@ fn is_whitespace(s: str) -> bool {
}
alt
argstr
{
option
::
some
(
s
)
{
rm_whitespace
(
str
::
split_
byte
(
s
,
' '
as
u8
))
}
option
::
some
(
s
)
{
rm_whitespace
(
str
::
split_
char
(
s
,
' '
))
}
option
::
none
{
[]
}
}
}
...
...
@@ -410,12 +410,10 @@ fn make_out_name(config: config, testfile: str, extension: str) -> str {
fn
output_base_name
(
config
:
config
,
testfile
:
str
)
->
str
{
let
base
=
config
.build_base
;
let
filename
=
{
let
parts
=
str
::
split_byte
(
fs
::
basename
(
testfile
),
'.'
as
u8
);
parts
=
vec
::
slice
(
parts
,
0u
,
vec
::
len
(
parts
)
-
1u
);
str
::
connect
(
parts
,
"."
)
};
let
filename
=
{
let
parts
=
str
::
split_char
(
fs
::
basename
(
testfile
),
'.'
);
str
::
connect
(
vec
::
slice
(
parts
,
0u
,
vec
::
len
(
parts
)
-
1u
),
"."
)
};
#
fmt
[
"%s%s.%s"
,
base
,
filename
,
config
.stage_id
]
}
...
...
src/libcore/extfmt.rs
浏览文件 @
780f8277
...
...
@@ -320,16 +320,14 @@ fn conv_char(cv: conv, c: char) -> str {
fn
conv_str
(
cv
:
conv
,
s
:
str
)
->
str
unsafe
{
// For strings, precision is the maximum characters
// displayed
let
unpadded
=
alt
cv
.precision
{
count_implied
{
s
}
count_is
(
max
)
{
if
max
as
uint
<
str
::
len_chars
(
s
)
{
str
::
substr
(
s
,
0u
,
max
as
uint
)
}
else
{
s
}
}
};
let
unpadded
=
alt
cv
.precision
{
count_implied
{
s
}
count_is
(
max
)
{
if
max
as
uint
<
str
::
char_len
(
s
)
{
str
::
substr
(
s
,
0u
,
max
as
uint
)
}
else
{
s
}
}
};
ret
pad
(
cv
,
unpadded
,
pad_nozero
);
}
fn
conv_float
(
cv
:
conv
,
f
:
float
)
->
str
{
...
...
@@ -368,7 +366,7 @@ fn uint_to_str_prec(num: uint, radix: uint, prec: uint) -> str {
""
}
else
{
let
s
=
uint
::
to_str
(
num
,
radix
);
let
len
=
str
::
len_chars
(
s
);
let
len
=
str
::
char_len
(
s
);
if
len
<
prec
{
let
diff
=
prec
-
len
;
let
pad
=
str_init_elt
(
diff
,
'0'
);
...
...
@@ -400,7 +398,7 @@ fn pad(cv: conv, s: str, mode: pad_mode) -> str unsafe {
uwidth
=
width
as
uint
;
}
}
let
strlen
=
str
::
len_chars
(
s
);
let
strlen
=
str
::
char_len
(
s
);
if
uwidth
<=
strlen
{
ret
s
;
}
let
padchar
=
' '
;
let
diff
=
uwidth
-
strlen
;
...
...
src/libcore/str.rs
浏览文件 @
780f8277
此差异已折叠。
点击以展开。
src/libstd/fs.rs
浏览文件 @
780f8277
...
...
@@ -33,19 +33,15 @@
type
path
=
str
;
fn
splitDirnameBasename
(
pp
:
path
)
->
{
dirname
:
str
,
basename
:
str
}
{
let
ii
;
alt
str
::
rindex
(
pp
,
os_fs
::
path_sep
)
{
option
::
some
(
xx
)
{
ii
=
xx
;
}
option
::
none
{
alt
str
::
rindex
(
pp
,
os_fs
::
alt_path_sep
)
{
option
::
some
(
xx
)
{
ii
=
xx
;
}
option
::
none
{
ret
{
dirname
:
"."
,
basename
:
pp
};
}
}
}
alt
str
::
rfind
(
pp
,
{|
ch
|
ch
==
os_fs
::
path_sep
||
ch
==
os_fs
::
alt_path_sep
})
{
some
(
i
)
{
{
dirname
:
str
::
slice
(
pp
,
0u
,
i
),
basename
:
str
::
slice
(
pp
,
i
+
1u
,
str
::
len
(
pp
))}
}
none
{
{
dirname
:
"."
,
basename
:
pp
}
}
}
ret
{
dirname
:
str
::
slice
(
pp
,
0u
,
ii
),
basename
:
str
::
slice
(
pp
,
ii
+
1u
,
str
::
len
(
pp
))};
}
/*
...
...
src/libstd/json.rs
浏览文件 @
780f8277
...
...
@@ -3,10 +3,6 @@
import
float
;
import
map
;
import
core
::
option
;
import
option
::{
some
,
none
};
import
str
;
import
vec
;
export
json
;
export
to_str
;
...
...
src/libstd/rope.rs
浏览文件 @
780f8277
...
...
@@ -743,7 +743,7 @@ fn of_str(str: @str) -> @node {
*/
fn
of_substr
(
str
:
@
str
,
byte_start
:
uint
,
byte_len
:
uint
)
->
@
node
{
ret
of_substr_unsafer
(
str
,
byte_start
,
byte_len
,
str
::
substr_len
_chars
(
*
str
,
byte_start
,
byte_len
));
str
::
count
_chars
(
*
str
,
byte_start
,
byte_len
));
}
/*
...
...
@@ -795,7 +795,7 @@ fn of_substr_unsafer(str: @str, byte_start: uint, byte_len: uint,
if
i
==
0u
{
first_leaf_char_len
}
else
{
hint_max_leaf_char_len
};
let
chunk_byte_len
=
str
::
substr_len
(
*
str
,
offset
,
chunk_char_len
);
str
::
count_bytes
(
*
str
,
offset
,
chunk_char_len
);
nodes
[
i
]
=
@
leaf
({
byte_offset
:
offset
,
byte_len
:
chunk_byte_len
,
...
...
@@ -998,7 +998,7 @@ fn sub_bytes(node: @node, byte_offset: uint, byte_len: uint) -> @node {
alt
(
*
node
)
{
node
::
leaf
(
x
)
{
let
char_len
=
str
::
substr_len
_chars
(
*
x
.content
,
byte_offset
,
byte_len
);
str
::
count
_chars
(
*
x
.content
,
byte_offset
,
byte_len
);
ret
@
leaf
({
byte_offset
:
byte_offset
,
byte_len
:
byte_len
,
char_len
:
char_len
,
...
...
@@ -1059,9 +1059,9 @@ fn sub_chars(node: @node, char_offset: uint, char_len: uint) -> @node {
ret
node
;
}
let
byte_offset
=
str
::
substr_len
(
*
x
.content
,
0u
,
char_offset
);
str
::
count_bytes
(
*
x
.content
,
0u
,
char_offset
);
let
byte_len
=
str
::
substr_len
(
*
x
.content
,
byte_offset
,
char_len
);
str
::
count_bytes
(
*
x
.content
,
byte_offset
,
char_len
);
ret
@
leaf
({
byte_offset
:
byte_offset
,
byte_len
:
byte_len
,
char_len
:
char_len
,
...
...
@@ -1138,9 +1138,9 @@ fn cmp(a: @node, b: @node) -> int {
fn
loop_chars
(
node
:
@
node
,
it
:
fn
(
char
)
->
bool
)
->
bool
{
ret
loop_leaves
(
node
,
{|
leaf
|
ret
str
::
substr_all
(
*
leaf
.content
,
leaf
.byte_offset
,
leaf
.byte_len
,
it
)
ret
str
::
all_between
(
*
leaf
.content
,
leaf
.byte_offset
,
leaf
.byte_len
,
it
)
})
}
...
...
@@ -1373,7 +1373,7 @@ fn of_string1() {
let
sample
=
@
"0123456789ABCDE"
;
let
r
=
of_str
(
sample
);
assert
char_len
(
r
)
==
str
::
len_chars
(
*
sample
);
assert
char_len
(
r
)
==
str
::
char_len
(
*
sample
);
assert
rope_to_string
(
r
)
==
*
sample
;
}
...
...
@@ -1384,7 +1384,7 @@ fn of_string2() {
while
i
<
10
{
*
buf
=
*
buf
+
*
buf
;
i
+=
1
;}
let
sample
=
@*
buf
;
let
r
=
of_str
(
sample
);
assert
char_len
(
r
)
==
str
::
len_chars
(
*
sample
);
assert
char_len
(
r
)
==
str
::
char_len
(
*
sample
);
assert
rope_to_string
(
r
)
==
*
sample
;
let
string_iter
=
0u
;
...
...
@@ -1427,7 +1427,7 @@ fn iter1() {
}
}
assert
len
==
str
::
len_chars
(
*
sample
);
assert
len
==
str
::
char_len
(
*
sample
);
}
#[test]
...
...
src/rustdoc/desc_pass.rs
浏览文件 @
780f8277
...
...
@@ -282,7 +282,7 @@ fn mk_doc(source: str) -> doc::cratedoc {
astsrv
::
from_str
(
source
)
{|
srv
|
let
doc
=
extract
::
from_srv
(
srv
,
""
);
let
doc
=
attr_pass
::
mk_pass
()(
srv
,
doc
);
mk_pass
(
str
::
trim
)(
srv
,
doc
)
mk_pass
(
{|
s
|
str
::
trim
(
s
)}
)(
srv
,
doc
)
}
}
}
\ No newline at end of file
src/rustdoc/markdown_pass.rs
浏览文件 @
780f8277
...
...
@@ -56,10 +56,10 @@ mod c { }\
fn d() { }"
);
let
idx_a
=
option
::
get
(
str
::
find
(
markdown
,
"# Module `a`"
));
let
idx_b
=
option
::
get
(
str
::
find
(
markdown
,
"## Function `b`"
));
let
idx_c
=
option
::
get
(
str
::
find
(
markdown
,
"# Module `c`"
));
let
idx_d
=
option
::
get
(
str
::
find
(
markdown
,
"## Function `d`"
));
let
idx_a
=
option
::
get
(
str
::
find
_str
(
markdown
,
"# Module `a`"
));
let
idx_b
=
option
::
get
(
str
::
find
_str
(
markdown
,
"## Function `b`"
));
let
idx_c
=
option
::
get
(
str
::
find
_str
(
markdown
,
"# Module `c`"
));
let
idx_d
=
option
::
get
(
str
::
find
_str
(
markdown
,
"## Function `d`"
));
assert
idx_b
<
idx_d
;
assert
idx_d
<
idx_a
;
...
...
src/rustdoc/trim_pass.rs
浏览文件 @
780f8277
...
...
@@ -10,7 +10,7 @@
export
mk_pass
;
fn
mk_pass
()
->
pass
{
desc_pass
::
mk_pass
(
str
::
trim
)
desc_pass
::
mk_pass
(
{|
s
|
str
::
trim
(
s
)}
)
}
#[test]
...
...
src/test/bench/sudoku.rs
浏览文件 @
780f8277
...
...
@@ -33,7 +33,7 @@ fn read_grid(f: io::reader) -> grid_t {
let
g
=
vec
::
init_fn
(
10u
,
{|
_
i
|
vec
::
init_elt_mut
(
10u
,
0
as
u8
)
});
while
!
f
.eof
()
{
let
comps
=
str
::
split_
byte
(
str
::
trim
(
f
.read_line
()),
','
as
u8
);
let
comps
=
str
::
split_
char
(
str
::
trim
(
f
.read_line
()),
','
);
if
vec
::
len
(
comps
)
>=
3u
{
let
row
=
option
::
get
(
uint
::
from_str
(
comps
[
0
]))
as
u8
;
let
col
=
option
::
get
(
uint
::
from_str
(
comps
[
1
]))
as
u8
;
...
...
src/test/compile-fail/fn-constraint.rs
浏览文件 @
780f8277
...
...
@@ -3,7 +3,8 @@
import
str
::
*
;
fn
main
()
unsafe
{
fn
foo
(
_
a
:
uint
,
_
b
:
uint
)
:
uint
::
le
(
_
a
,
_
b
)
{}
let
a
:
uint
=
4u
;
let
b
:
uint
=
1u
;
log
(
error
,
str
::
unsafe
::
slice_bytes_safe_range
(
"kitties"
,
a
,
b
));
log
(
error
,
foo
(
a
,
b
));
}
src/test/compile-fail/no-constraint-prop.rs
浏览文件 @
780f8277
// error-pattern:Unsatisfied precondition constraint (for example, uint::le
fn
main
()
unsafe
{
fn
foo
(
_
a
:
uint
,
_
b
:
uint
)
:
uint
::
le
(
_
a
,
_
b
)
{}
let
a
:
uint
=
1u
;
let
b
:
uint
=
4u
;
let
c
:
uint
=
5u
;
...
...
@@ -13,5 +14,5 @@ fn main() unsafe {
// the next statement, since it's not true in the
// prestate.
let
d
<-
a
;
log
(
debug
,
str
::
unsafe
::
slice_bytes_safe_range
(
"kitties"
,
b
,
d
));
log
(
debug
,
foo
(
b
,
d
));
}
src/test/run-fail/fn-constraint.rs
浏览文件 @
780f8277
// error-pattern:Predicate uint::le(a, b) failed
fn
main
()
unsafe
{
fn
foo
(
_
a
:
uint
,
_
b
:
uint
)
:
uint
::
le
(
_
a
,
_
b
)
{}
let
a
:
uint
=
4u
;
let
b
:
uint
=
1u
;
check
(
uint
::
le
(
a
,
b
));
log
(
error
,
str
::
unsafe
::
slice_bytes_safe_range
(
"kitties"
,
a
,
b
));
log
(
error
,
foo
(
a
,
b
));
}
src/test/run-pass/constraint-prop-expr-move.rs
浏览文件 @
780f8277
fn
main
()
unsafe
{
fn
foo
(
_
a
:
uint
,
_
b
:
uint
)
:
uint
::
le
(
_
a
,
_
b
)
{}
let
a
:
uint
=
1u
;
let
b
:
uint
=
4u
;
let
c
:
uint
=
17u
;
check
(
uint
::
le
(
a
,
b
));
c
<-
a
;
log
(
debug
,
str
::
unsafe
::
slice_bytes_safe_range
(
"kitties"
,
c
,
b
));
log
(
debug
,
foo
(
c
,
b
));
}
src/test/run-pass/constraint-prop-move.rs
浏览文件 @
780f8277
fn
main
()
unsafe
{
fn
foo
(
_
a
:
uint
,
_
b
:
uint
)
:
uint
::
le
(
_
a
,
_
b
)
{}
let
a
:
uint
=
1u
;
let
b
:
uint
=
4u
;
check
(
uint
::
le
(
a
,
b
));
let
c
<-
a
;
log
(
debug
,
str
::
unsafe
::
slice_bytes_safe_range
(
"kitties"
,
c
,
b
));
log
(
debug
,
foo
(
c
,
b
));
}
src/test/run-pass/constraint-prop-swap.rs
浏览文件 @
780f8277
fn
main
()
unsafe
{
fn
foo
(
_
a
:
uint
,
_
b
:
uint
)
:
uint
::
le
(
_
a
,
_
b
)
{}
let
a
:
uint
=
4u
;
let
b
:
uint
=
1u
;
check
(
uint
::
le
(
b
,
a
));
b
<->
a
;
log
(
debug
,
str
::
unsafe
::
slice_bytes_safe_range
(
"kitties"
,
a
,
b
));
log
(
debug
,
foo
(
a
,
b
));
}
src/test/run-pass/constraint-prop.rs
浏览文件 @
780f8277
fn
main
()
unsafe
{
fn
foo
(
_
a
:
uint
,
_
b
:
uint
)
:
uint
::
le
(
_
a
,
_
b
)
{}
let
a
:
uint
=
1u
;
let
b
:
uint
=
4u
;
check
(
uint
::
le
(
a
,
b
)
);
check
uint
::
le
(
a
,
b
);
let
c
=
b
;
log
(
debug
,
str
::
unsafe
::
slice_bytes_safe_range
(
"kitties"
,
a
,
c
));
log
(
debug
,
foo
(
a
,
c
));
}
src/test/run-pass/fn-constraint.rs
浏览文件 @
780f8277
fn
main
()
unsafe
{
fn
foo
(
_
a
:
uint
,
_
b
:
uint
)
:
uint
::
le
(
_
a
,
_
b
)
{}
let
a
:
uint
=
1u
;
let
b
:
uint
=
4u
;
check
(
uint
::
le
(
a
,
b
));
log
(
debug
,
str
::
unsafe
::
slice_bytes_safe_range
(
"kitties"
,
a
,
b
));
log
(
debug
,
foo
(
a
,
b
));
}
src/test/run-pass/utf8_chars.rs
浏览文件 @
780f8277
...
...
@@ -8,8 +8,8 @@ fn main() {
let
s
:
str
=
str
::
from_chars
(
chs
);
assert
(
str
::
len
(
s
)
==
10u
);
assert
(
str
::
len_chars
(
s
)
==
4u
);
assert
(
vec
::
len
::
<
char
>
(
str
::
chars
(
s
))
==
4u
);
assert
(
str
::
char_len
(
s
)
==
4u
);
assert
(
vec
::
len
(
str
::
chars
(
s
))
==
4u
);
assert
(
str
::
eq
(
str
::
from_chars
(
str
::
chars
(
s
)),
s
));
assert
(
str
::
char_at
(
s
,
0u
)
==
'e'
);
assert
(
str
::
char_at
(
s
,
1u
)
==
'é'
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录